gecko-dev/third_party/rust/parity-wasm
Mike Hommey b28df3b531 Bug 1587468 - Update object to 0.16.0 and goblin to 0.1.2. r=emilio
This has the side effect of adding another version of uuid, which we'll
upgrade for other dependencies subsequently.

Differential Revision: https://phabricator.services.mozilla.com/D55911

--HG--
rename : third_party/rust/uuid/.cargo-checksum.json => third_party/rust/uuid-0.7.4/.cargo-checksum.json
rename : third_party/rust/uuid/Cargo.toml => third_party/rust/uuid-0.7.4/Cargo.toml
rename : third_party/rust/uuid/README.md => third_party/rust/uuid-0.7.4/README.md
rename : third_party/rust/uuid/README.tpl => third_party/rust/uuid-0.7.4/README.tpl
rename : third_party/rust/uuid/benches/format_str.rs => third_party/rust/uuid-0.7.4/benches/format_str.rs
rename : third_party/rust/uuid/benches/invalid_parse_str.rs => third_party/rust/uuid-0.7.4/benches/invalid_parse_str.rs
rename : third_party/rust/uuid/benches/mod.rs => third_party/rust/uuid-0.7.4/benches/mod.rs
rename : third_party/rust/uuid/benches/serde_support.rs => third_party/rust/uuid-0.7.4/benches/serde_support.rs
rename : third_party/rust/uuid/benches/slog_support/mod.rs => third_party/rust/uuid-0.7.4/benches/slog_support/mod.rs
rename : third_party/rust/uuid/benches/slog_support/parse_str.rs => third_party/rust/uuid-0.7.4/benches/slog_support/parse_str.rs
rename : third_party/rust/uuid/benches/valid_parse_str.rs => third_party/rust/uuid-0.7.4/benches/valid_parse_str.rs
rename : third_party/rust/uuid/src/adapter/compact.rs => third_party/rust/uuid-0.7.4/src/adapter/compact.rs
rename : third_party/rust/uuid/src/adapter/core_support/mod.rs => third_party/rust/uuid-0.7.4/src/adapter/core_support/mod.rs
rename : third_party/rust/uuid/src/adapter/mod.rs => third_party/rust/uuid-0.7.4/src/adapter/mod.rs
rename : third_party/rust/uuid/src/builder.rs => third_party/rust/uuid-0.7.4/src/builder.rs
rename : third_party/rust/uuid/src/core_support.rs => third_party/rust/uuid-0.7.4/src/core_support.rs
rename : third_party/rust/uuid/src/lib.rs => third_party/rust/uuid-0.7.4/src/lib.rs
rename : third_party/rust/uuid/src/parser/core_support.rs => third_party/rust/uuid-0.7.4/src/parser/core_support.rs
rename : third_party/rust/uuid/src/parser/mod.rs => third_party/rust/uuid-0.7.4/src/parser/mod.rs
rename : third_party/rust/uuid/src/parser/std_support.rs => third_party/rust/uuid-0.7.4/src/parser/std_support.rs
rename : third_party/rust/uuid/src/prelude.rs => third_party/rust/uuid-0.7.4/src/prelude.rs
rename : third_party/rust/uuid/src/serde_support.rs => third_party/rust/uuid-0.7.4/src/serde_support.rs
rename : third_party/rust/uuid/src/slog_support.rs => third_party/rust/uuid-0.7.4/src/slog_support.rs
rename : third_party/rust/uuid/src/std_support.rs => third_party/rust/uuid-0.7.4/src/std_support.rs
rename : third_party/rust/uuid/src/test_util.rs => third_party/rust/uuid-0.7.4/src/test_util.rs
rename : third_party/rust/uuid/src/u128_support.rs => third_party/rust/uuid-0.7.4/src/u128_support.rs
rename : third_party/rust/uuid/src/v1.rs => third_party/rust/uuid-0.7.4/src/v1.rs
rename : third_party/rust/uuid/src/v3.rs => third_party/rust/uuid-0.7.4/src/v3.rs
rename : third_party/rust/uuid/src/v4.rs => third_party/rust/uuid-0.7.4/src/v4.rs
rename : third_party/rust/uuid/src/v5.rs => third_party/rust/uuid-0.7.4/src/v5.rs
rename : third_party/rust/uuid/src/winapi_support.rs => third_party/rust/uuid-0.7.4/src/winapi_support.rs
extra : moz-landing-system : lando
2019-12-06 00:33:03 +00:00
..
examples
src
.cargo-checksum.json
Cargo.lock
Cargo.toml
LICENSE-APACHE
LICENSE-MIT
README.md

README.md

parity-wasm

Low-level WebAssembly format library.

Build Status crates.io link

Documentation

Rust WebAssembly format serializing/deserializing

Add to Cargo.toml

[dependencies]
parity-wasm = "0.41"

and then

let module = parity_wasm::deserialize_file("./res/cases/v1/hello.wasm").unwrap();
assert!(module.code_section().is_some());

let code_section = module.code_section().unwrap(); // Part of the module with functions code

println!("Function count in wasm file: {}", code_section.bodies().len());

Wabt Test suite

parity-wasm supports full wabt testsuite (https://github.com/WebAssembly/testsuite), running asserts that involves deserialization.

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)
  • checkout with submodules (git submodule update --init --recursive)
  • run cargo test --release --manifest-path=spec/Cargo.toml

Decoder can be fuzzed with cargo-fuzz using wasm-opt (https://github.com/WebAssembly/binaryen):

  • 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

no_std crates

This crate has a feature, std, that is enabled by default. To use this crate in a no_std context, add the following to your Cargo.toml (still requires allocator though):

[dependencies]
parity-wasm = { version = "0.41", default-features = false }

License

parity-wasm is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), at your choice.

See LICENSE-APACHE, and LICENSE-MIT for details.

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.