145 stable releases
| 1.240.0 | Oct 8, 2025 |
|---|---|
| 1.238.0 | Aug 26, 2025 |
| 1.236.0 | Jul 28, 2025 |
| 1.227.1 | Mar 7, 2025 |
| 0.1.0 |
|
#8 in WebAssembly
643,135 downloads per month
Used in 645 crates
(155 directly)
765KB
17K
SLoC
Usage
Add wat to your Cargo.toml
$ cargo add wat
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)?;
AST Representation
The wat crate does not expose an AST as its goal is to provide a
forever-stable interface against the wast crate. Using wat is suitable when
all you want to do is translate from text-to-binary, for example parsing the
input of a CLI program into the WebAssembly binary format.
If instead you're interested in working with the AST of a text file or otherwise
adding your own parsing to the text format you'll want to take a look at the
wast crate.
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
~5.5MB
~95K SLoC