| 1 |
<div align="center"> |
| 2 |
<h1><code>wasmprinter</code></h1> |
| 3 |
|
| 4 |
<strong>A <a href="https://bytecodealliance.org/">Bytecode Alliance</a> project</strong> |
| 5 |
|
| 6 |
<p> |
| 7 |
<strong>A Rust parser for printing a WebAssembly binary in the <a href="https://webassembly.github.io/spec/core/text/index.html">WebAssembly Text Format (WAT)</a>.</strong> |
| 8 |
</p> |
| 9 |
|
| 10 |
<p> |
| 11 |
<a href="https://crates.io/crates/wasmprinter"><img src="https://img.shields.io/crates/v/wasmprinter.svg?style=flat-square" alt="Crates.io version" /></a> |
| 12 |
<a href="https://crates.io/crates/wasmprinter"><img src="https://img.shields.io/crates/d/wasmprinter.svg?style=flat-square" alt="Download" /></a> |
| 13 |
<a href="https://docs.rs/wasmprinter/"><img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square" alt="docs.rs docs" /></a> |
| 14 |
</p> |
| 15 |
</div> |
| 16 |
|
| 17 |
## Usage |
| 18 |
|
| 19 |
Add `wasmprinter` to your `Cargo.toml` |
| 20 |
|
| 21 |
```sh |
| 22 |
$ cargo add wasmprinter |
| 23 |
``` |
| 24 |
|
| 25 |
You can then convert wasm binaries to strings like so: |
| 26 |
|
| 27 |
```rust |
| 28 |
fn main() -> Result<()> { |
| 29 |
let foo_wat = wasmprinter::print_file("path/to/foo.wasm")?; |
| 30 |
|
| 31 |
let binary = /* ... */; |
| 32 |
let wat = wasmprinter::print_bytes(&binary)?; |
| 33 |
|
| 34 |
// ... |
| 35 |
} |
| 36 |
``` |
| 37 |
|
| 38 |
## License |
| 39 |
|
| 40 |
This project is licensed under the Apache 2.0 license with the LLVM exception. |
| 41 |
See [LICENSE](LICENSE) for more details. |
| 42 |
|
| 43 |
### Contribution |
| 44 |
|
| 45 |
Unless you explicitly state otherwise, any contribution intentionally submitted |
| 46 |
for inclusion in this project by you, as defined in the Apache-2.0 license, |
| 47 |
shall be licensed as above, without any additional terms or conditions. |