summaryrefslogtreecommitdiff
path: root/crates/parser/README.md
diff options
context:
space:
mode:
authorHenry <mail@henrygressmann.de>2026-04-26 17:55:48 +0200
committerHenry <mail@henrygressmann.de>2026-04-26 17:55:48 +0200
commit27004a8738c7a3c32ac4fb6966f32647b4c96db7 (patch)
treebc3d663d1dc246df20ed30b1ecd0c19935c0f8bb /crates/parser/README.md
parent40bd20bb77b611f7974036c9f2b152a16a46c32a (diff)
docs: rework documentation, prepare pre-release
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/parser/README.md')
-rw-r--r--crates/parser/README.md19
1 files changed, 14 insertions, 5 deletions
diff --git a/crates/parser/README.md b/crates/parser/README.md
index c7eef8d..91145f1 100644
--- a/crates/parser/README.md
+++ b/crates/parser/README.md
@@ -1,20 +1,29 @@
# `tinywasm-parser`
-This crate provides a compiler that can convert WebAssembly modules into a `tinywasm` modules.
+This crate provides the parser and lowering pipeline that converts WebAssembly binaries into `tinywasm` modules.
## Features
- `std`: Enables the use of `std` and `std::io` for parsing from files and streams.
- `log`: Enables logging of the parsing process using the `log` crate.
+- `parallel`: Enables multithreaded parsing and validation when `std` is available.
## Usage
```rust
-use tinywasm_parser::Parser;
+use tinywasm_parser::{Parser, ParserOptions};
+
let bytes = include_bytes!("./file.wasm");
let parser = Parser::new();
-let module = parser.parse_module_bytes(bytes).unwrap();
-let module = parser.parse_module_file("path/to/file.wasm").unwrap();
-let module = parser.parse_module_stream(&mut stream).unwrap();
+let module = parser.parse_module_bytes(bytes)?;
+
+let parser = Parser::with_options(ParserOptions::default().with_rewrite_optimization(false));
+let module = parser.parse_module_bytes(bytes)?;
+
+let module = parser.parse_module_file("path/to/file.wasm")?;
+let mut stream = std::fs::File::open("path/to/file.wasm")?;
+let module = parser.parse_module_stream(&mut stream)?;
```
+
+If you just want the default configuration, the top-level `parse_bytes`, `parse_file`, and `parse_stream` helpers are thin wrappers around `Parser::new()`.