Crate fizzy

source · []
Expand description

This is a Rust interface to Fizzy, a fast, deterministic, and pedantic WebAssembly interpreter.


This is a generic example for parsing and instantiating a module, and executing a simple function with inputs and an output.

extern crate fizzy;

fn main() {
    // This wasm binary exports a single sum(u32, u32) -> u32 function.
    let wasm = [
        0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x60, 0x02, 0x7f,
        0x7f, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x07, 0x07, 0x01, 0x03, 0x73, 0x75, 0x6d,
        0x00, 0x00, 0x0a, 0x09, 0x01, 0x07, 0x00, 0x20, 0x00, 0x20, 0x01, 0x6a, 0x0b,
    let module = fizzy::parse(&wasm).expect("parsing failed");
    let mut instance = module.instantiate().expect("instantiation failed");
    let result = instance
            &[fizzy::TypedValue::U32(42), fizzy::TypedValue::U32(24)],
        .expect("execution failed");
    let result = result
        .expect("return value expected")
        .expect("u32 expected as a return type");
    assert_eq!(result, 66);


The result of an execution.

An instance of a module.

A parsed and validated WebAssembly 1.0 module.


The various kinds of errors, which can be returned by any of the interfaces.

A WebAssembly value i32/i64/f32/f64 with its type specified.


Parse and validate the input according to WebAssembly 1.0 rules.

Parse and validate the input according to WebAssembly 1.0 rules. Returns true if the supplied input is valid.

Type Definitions

A WebAssembly value of i32/i64/f32/f64.