• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..15-Mar-2021-

examples/H15-Mar-2021-384251

src/H15-Mar-2021-10,7228,402

.cargo-checksum.jsonH A D15-Mar-20213.6 KiB11

Cargo.lockH A D15-Mar-20212.3 KiB5648

Cargo.tomlH A D15-Mar-20211.3 KiB3734

LICENSE-APACHEH A D15-Mar-202110.6 KiB202169

LICENSE-MITH A D15-Mar-20211.1 KiB2622

README.mdH A D15-Mar-20212.4 KiB6945

README.md

1# parity-wasm
2
3Low-level WebAssembly format library.
4
5[![Build Status](https://travis-ci.org/paritytech/parity-wasm.svg?branch=master)](https://travis-ci.org/paritytech/parity-wasm)
6[![crates.io link](https://img.shields.io/crates/v/parity-wasm.svg)](https://crates.io/crates/parity-wasm)
7
8[Documentation](https://docs.rs/parity-wasm/0.40.2/parity_wasm/)
9
10## Rust WebAssembly format serializing/deserializing
11
12Add to Cargo.toml
13
14```toml
15[dependencies]
16parity-wasm = "0.41"
17```
18
19and then
20
21```rust
22let module = parity_wasm::deserialize_file("./res/cases/v1/hello.wasm").unwrap();
23assert!(module.code_section().is_some());
24
25let code_section = module.code_section().unwrap(); // Part of the module with functions code
26
27println!("Function count in wasm file: {}", code_section.bodies().len());
28```
29
30## Wabt Test suite
31
32`parity-wasm` supports full wabt testsuite (https://github.com/WebAssembly/testsuite), running asserts that involves deserialization.
33
34To run testsuite:
35- make sure you have all prerequisites to build `wabt` (since parity-wasm builds it internally using `wabt-rs`, see https://github.com/WebAssembly/wabt)
36- checkout with submodules (`git submodule update --init --recursive`)
37- run `cargo test --release --manifest-path=spec/Cargo.toml`
38
39Decoder can be fuzzed with `cargo-fuzz` using `wasm-opt` (https://github.com/WebAssembly/binaryen):
40
41- make sure you have all prerequisites to build `binaryen` and `cargo-fuzz` (`cmake` and a C++11 toolchain)
42- checkout with submodules (`git submodule update --init --recursive`)
43- install `cargo fuzz` subcommand with `cargo install cargo-fuzz`
44- set rustup to use a nightly toolchain, because `cargo fuzz` uses a rust compiler plugin: `rustup override set nightly`
45- run `cargo fuzz run deserialize`
46
47## `no_std` crates
48
49This crate has a feature, `std`, that is enabled by default. To use this crate
50in a `no_std` context, add the following to your `Cargo.toml` (still requires allocator though):
51
52```toml
53[dependencies]
54parity-wasm = { version = "0.41", default-features = false }
55```
56
57# License
58
59`parity-wasm` is primarily distributed under the terms of both the MIT
60license and the Apache License (Version 2.0), at your choice.
61
62See LICENSE-APACHE, and LICENSE-MIT for details.
63
64### Contribution
65
66Unless you explicitly state otherwise, any contribution intentionally submitted
67for inclusion in parity-wasm by you, as defined in the Apache-2.0 license, shall be
68dual licensed as above, without any additional terms or conditions.
69