wain-syntax-binary

crates.io CI

wain-syntax-binary is a crate to parse WebAssembly binary format files.

This crate is part of larger wain project.

Installation

toml [dependencies] wain-syntax-binary = "0"

Usage

Using wain_syntax_binary::parse() is the easiest way.

```rust extern crate wainsyntaxbinary;

use std::fs; use wainsyntaxbinary::parse;

let source = fs::read("foo.wasm").unwrap();

match parse(&source) { Ok(tree) => { /* tree is wain_ast::Root value */ } Err(err) => eprintln!("Error! {}", err), } ```

For the syntax tree structure parsed by this library, please see wain-ast crate.

Using Parser struct, it can parse part of Wasm binary.

```rust extern crate wainsyntaxbinary;

use std::fs; use wainsyntaxbinary::Parser; use wain_ast::DataSegment;

let source = fs::read("datasegmentonly.bin").unwrap();

// Parse only data segment let data: DataSegment<'_> = Parser.parse().unwrap(); ```

Working examples can be seen at examples/api/ directory

Please read documentation (not yet) for details.

License

the MIT license