24 stable releases

1.0.25 Sep 9, 2020
1.0.22 Jun 25, 2020
1.0.13 Mar 27, 2020
1.0.6 Dec 18, 2019
0.1.0 Sep 23, 2016

#29 in WebAssembly

Download history 6939/week @ 2020-06-04 6534/week @ 2020-06-11 7521/week @ 2020-06-18 7146/week @ 2020-06-25 6432/week @ 2020-07-02 5881/week @ 2020-07-09 7385/week @ 2020-07-16 5845/week @ 2020-07-23 6319/week @ 2020-07-30 6172/week @ 2020-08-06 5222/week @ 2020-08-13 7344/week @ 2020-08-20 6089/week @ 2020-08-27 6615/week @ 2020-09-03 8397/week @ 2020-09-10 7409/week @ 2020-09-17

28,441 downloads per month
Used in 28 crates (14 directly)

Apache-2.0 WITH LLVM-exception

470KB
10K SLoC

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.

Dependencies