diff options
| author | Henry <mail@henrygressmann.de> | 2026-04-26 17:55:48 +0200 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2026-04-26 17:55:48 +0200 |
| commit | 27004a8738c7a3c32ac4fb6966f32647b4c96db7 (patch) | |
| tree | bc3d663d1dc246df20ed30b1ecd0c19935c0f8bb /crates/parser | |
| parent | 40bd20bb77b611f7974036c9f2b152a16a46c32a (diff) | |
docs: rework documentation, prepare pre-release
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/parser')
| -rw-r--r-- | crates/parser/Cargo.toml | 3 | ||||
| -rw-r--r-- | crates/parser/README.md | 19 |
2 files changed, 16 insertions, 6 deletions
diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml index 26bdd51..1c228c4 100644 --- a/crates/parser/Cargo.toml +++ b/crates/parser/Cargo.toml @@ -1,7 +1,7 @@ [package] name="tinywasm-parser" version.workspace=true -description="TinyWasm parser" +description="Parser and lowering pipeline for TinyWasm" edition.workspace=true license.workspace=true authors.workspace=true @@ -9,6 +9,7 @@ repository.workspace=true rust-version.workspace=true keywords.workspace=true categories.workspace=true +readme="README.md" [dependencies] wasmparser={workspace=true, features=["validate", "features", "simd"]} 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()`. |
