[][src]Function wabt::wat2wasm

pub fn wat2wasm<S: AsRef<[u8]>>(source: S) -> 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.

This function will make translation with default parameters. If you want to find out what default parameters are or you want to tweak them you can use Wat2Wasm

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