Function wabt::wat2wasm [] [src]

pub fn wat2wasm(src: &str) -> Result<Vec<u8>, Error>

Translate wasm text source to wasm binary format.

If wasm source is valid wasm binary will be returned in the vector. Returned binary is validated and can be executed.

For more examples and online demo you can check online version of wat2wasm.

Examples

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
        ]
    );
}