gecko-dev/third_party/rust/wat
Ryan Hunt 7157eeec3a Bug 1561521 - Vendor the latest wat. r=lth
Differential Revision: https://phabricator.services.mozilla.com/D85052
2020-08-18 16:50:27 +00:00
..
src Bug 1612534 - Include vendored files. r=lth 2020-03-23 16:16:46 +00:00
.cargo-checksum.json Bug 1561521 - Vendor the latest wat. r=lth 2020-08-18 16:50:27 +00:00
Cargo.toml Bug 1561521 - Vendor the latest wat. r=lth 2020-08-18 16:50:27 +00:00
README.md Bug 1642589 - Pull in new wat crate. r=rhunt 2020-06-08 08:01:13 +00:00

README.md

wat

A Bytecode Alliance project

A Rust parser for the WebAssembly Text Format (WAT).

Crates.io version Download docs.rs docs docs.rs docs

Usage

Add this to your Cargo.toml:

[dependencies]
wat = "1.0"

And then you can parse WAT to binary WebAssembly via:

// Parse from a file ...
let binary = wat::parse_file("./foo.wat")?;

// ... or a string
let wat = r#"
    (module
        (func $foo)

        (func (export "bar")
            call $foo
        )
    )
"#;
let binary = wat::parse_str(wat)?;

Low-level parsing

This repository and project also aims to provide low-level parsing support for the WAT and WAST formats. Effectively, if you've got an s-expression lookalike that you'd like to parse, you should be able to parse it!

The wat crate does not support this because it strives to provide strong API-level stability guarantees, but the wast crate has all the low-level details and is the implementation of the wast crate. Be sure to check out its README.md for more information.

Stability and WebAssembly Features

Consult the crate documentation for more information, but the general idea is this crate will not issue a semver-breaking change for breaking changes in the WAT format, either for MVP features or post-MVP features. No opt-in is required to use WebAssembly features, so using them may break if the upstream spec changes.

License

This project is licensed under the Apache 2.0 license with the LLVM exception. See LICENSE for more details.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.