[][src]Struct wabt::Wat2Wasm

pub struct Wat2Wasm { /* fields omitted */ }

A builder for translating wasm text source to wasm binary format.

This version allows you to tweak parameters. If you need simple version check out wat2wasm.

Examples

extern crate wabt;
use wabt::Wat2Wasm;

fn main() {
    let wasm_binary = Wat2Wasm::new()
        .canonicalize_lebs(false)
        .write_debug_names(true)
        .convert(
            r#"
                (module
                    (import "spectest" "print" (func $print (param i32)))
                    (func (export "main")
                        i32.const 1312
                        call $print
                    )
                )
            "#
        ).unwrap();

}

Implementations

impl Wat2Wasm[src]

pub fn new() -> Wat2Wasm[src]

Create Wat2Wasm with default configuration.

pub fn canonicalize_lebs(&mut self, canonicalize_lebs: bool) -> &mut Wat2Wasm[src]

Write canonicalized LEB128 for var ints.

Set this to false to write all LEB128 sizes as 5-bytes instead of their minimal size. true by default.

pub fn relocatable(&mut self, relocatable: bool) -> &mut Wat2Wasm[src]

Create a relocatable wasm binary

(suitable for linking with wasm-link). false by default.

pub fn write_debug_names(&mut self, write_debug_names: bool) -> &mut Wat2Wasm[src]

Write debug names to the generated binary file

false by default.

pub fn validate(&mut self, validate: bool) -> &mut Wat2Wasm[src]

Check for validity of module before writing.

true by default.

pub fn convert<S: AsRef<[u8]>>(&self, source: S) -> Result<WabtBuf, Error>[src]

Perform conversion.

Auto Trait Implementations

impl RefUnwindSafe for Wat2Wasm

impl !Send for Wat2Wasm

impl !Sync for Wat2Wasm

impl Unpin for Wat2Wasm

impl UnwindSafe for Wat2Wasm

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> FromBits<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.