2017-04-04 16:06:58 +03:00
# parity-wasm
2018-02-21 13:41:05 +03:00
Low-level WebAssembly format library.
2017-10-24 15:11:50 +03:00
[](https://travis-ci.org/paritytech/parity-wasm)
2017-05-30 22:45:14 +04:00
[](https://crates.io/crates/parity-wasm)
2017-04-04 16:15:05 +03:00
2017-11-20 13:36:07 +03:00
[Documentation ](https://paritytech.github.io/parity-wasm/parity_wasm/ )
2017-04-04 16:43:30 +03:00
2017-04-04 16:08:20 +03:00
## Rust WebAssembly format serializing/deserializing
2017-04-04 16:06:58 +03:00
```rust
extern crate parity_wasm;
2018-01-09 13:38:09 -05:00
let module = parity_wasm::deserialize_file("./res/cases/v1/hello.wasm").unwrap();
assert!(module.code_section().is_some());
2017-04-04 16:07:55 +03:00
let code_section = module.code_section().unwrap(); // Part of the module with functions code
println!("Function count in wasm file: {}", code_section.bodies().len());
2017-04-04 16:06:58 +03:00
```
2017-04-04 16:48:01 +03:00
2017-06-05 17:05:11 +04:00
## Wabt Test suite
2018-02-21 13:41:05 +03:00
`parity-wasm` supports full wabt testsuite (https://github.com/WebAssembly/testsuite), running asserts that invloves deserialization.
2017-06-05 17:05:11 +04:00
2018-02-21 13:41:05 +03:00
To run testsuite:
- make sure you have all prerequisites to build `wabt` (since parity-wasm builds it internally using `wabt-rs` , see https://github.com/WebAssembly/wabt)
2017-09-11 15:14:01 +03:00
- checkout with submodules (`git submodule update --init --recursive` )
2017-06-05 17:05:11 +04:00
- run `cargo test --release --manifest-path=spec/Cargo.toml`
2017-09-09 16:39:58 +03:00
Decoder can be fuzzed with `cargo-fuzz` using `wasm-opt` (https://github.com/WebAssembly/binaryen):
2017-09-07 13:06:50 -07:00
- make sure you have all prerequisites to build `binaryen` and `cargo-fuzz` (`cmake` and a C++11 toolchain)
- checkout with submodules (`git submodule update --init --recursive` )
- install `cargo fuzz` subcommand with `cargo install cargo-fuzz`
- set rustup to use a nightly toolchain, because `cargo fuzz` uses a rust compiler plugin: `rustup override set nightly`
- run `cargo fuzz run deserialize`
2017-04-04 16:48:01 +03:00
# License
`parity-wasm` is primarily distributed under the terms of both the MIT
license and the Apache License (Version 2.0), at your choice.
2017-05-23 17:37:57 +04:00
See LICENSE-APACHE, and LICENSE-MIT for details.
2018-01-23 19:47:33 +03:00
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in parity-wasm by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.