Crates.io | wain-syntax-binary |
lib.rs | wain-syntax-binary |
version | 0.1.5 |
source | src |
created_at | 2020-03-29 12:25:14.89798 |
updated_at | 2023-11-18 04:38:29.646236 |
description | WebAssembly binary format parser for wain project |
homepage | https://github.com/rhysd/wain/tree/master/wain-syntax-binary |
repository | https://github.com/rhysd/wain |
max_upload_size | |
id | 224049 |
size | 56,893 |
wain-syntax-binary
is a crate to parse WebAssembly binary format files.
This crate is part of larger wain project.
[dependencies]
wain-syntax-binary = "0"
Using wain_syntax_binary::parse()
is the easiest way.
extern crate wain_syntax_binary;
use std::fs;
use wain_syntax_binary::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.
extern crate wain_syntax_binary;
use std::fs;
use wain_syntax_binary::Parser;
use wain_ast::DataSegment;
let source = fs::read("data_segment_only.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.