wabt 0.1.8

Bindings to the wabt library
Documentation

WABT bindings for Rust

crates.io docs.rs

Rust bindings for WABT. Work in progress.

Usage

Add this to your Cargo.toml:

[dependencies]
wabt = "0.1"

Example

wat2wasm (previously known as wast2wasm):

extern crate wabt;
use wabt::wat2wasm;

fn main() {
    assert_eq!(
        wat2wasm("(module)").unwrap(),
        &[
            0, 97, 115, 109, // \0ASM - magic
            1, 0, 0, 0       //  0x01 - version
        ]
    );
}

wasm2wat:

extern crate wabt;
use wabt::wasm2wat;
fn main() {
    assert_eq!(
        wasm2wat(&[
            0, 97, 115, 109, // \0ASM - magic
            1, 0, 0, 0       //    01 - version
        ]),
        Ok("(module)\n".to_owned()),
    );
}