This crate provides the parser and lowering pipeline that converts WebAssembly binaries into tinywasm modules.
std: Enables the use ofstdandstd::iofor parsing from files and streams.log: Enables logging of the parsing process using thelogcrate.parallel: Enables multithreaded function parsing. Requiresstd.validate: Enableswasmparservalidation. Enabled by default and configurable throughParserOptions.unstable-component-model: Enablesparse_component_bytesand, withstd,parse_component_fileandparse_component_stream. These return an ownedComponentfor future linking, not an executable module.
With validation enabled, component parsing accepts the base Component Model and the features shipped through WASI Preview 0.3.1: async, maps, and implements annotations. The final Component Model 1.0 feature set is not yet defined.
Embedded core modules use the ordinary Module parser. Core proposals that it cannot lower remain unsupported inside components.
use tinywasm_parser::{Parser, ParserOptions};
let bytes = include_bytes!("./file.wasm");
let parser = Parser::default();
let module = parser.parse_module_bytes(bytes)?;
let parser = Parser::new(ParserOptions::default().with_optimize(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::default().
For untrusted modules, keep validation enabled and configure ParseLimits.