Skip to main content

Crate fizzyx

Crate fizzyx 

Source
Expand description

Safe, ergonomic Rust bindings for the Fizzy WebAssembly interpreter.

Fizzy is a small, fast, deterministic interpreter for the WebAssembly 1.0 (MVP) specification. This crate wraps its C API with an interface inspired by wasmi and wasmtime.

§Example

use fizzyx::{Engine, Linker, Module, Val};

let wat = r#"(module (func (export "add") (param i32 i32) (result i32)
    local.get 0
    local.get 1
    i32.add))"#;
let wasm = wat::parse_str(wat)?;

let engine = Engine::default();
let module = Module::new(&wasm)?;
let linker = Linker::new(&engine);
let mut instance = linker.instantiate(&module)?;

let add = instance.get_func("add").expect("missing export");
let mut results = [Val::I32(0)];
add.call(&mut instance, &[Val::I32(1), Val::I32(2)], &mut results)?;
assert_eq!(results[0], Val::I32(3));

§Relationship to wasmi/wasmtime

The API deliberately follows Fizzy’s own model rather than forcing a perfect match:

  • Fizzy targets WebAssembly 1.0, so a function returns at most one result.
  • Instances are self-contained (they own their memory and globals), so there is no Store type. Methods that mutate an instance take &mut Instance directly.
  • Imports are resolved by module::name at instantiation time via a Linker. Only function imports are currently supported.

Structs§

Config
Configuration for an Engine.
Engine
A Fizzy engine.
ExportType
A description of a single module export.
Func
A handle to a function exported by an Instance.
FuncType
The signature of a function: its parameter and result types.
Global
A handle to a global exported by an Instance.
GlobalType
The type of a global variable: its value type and mutability.
ImportType
A description of a single module import.
Instance
An instantiated WebAssembly module.
Linker
Collects host functions to satisfy a module’s imports and instantiates modules.
Memory
A handle to a linear memory exported by an Instance.
MemoryType
The type of a linear memory: its minimum and optional maximum size in pages.
Module
A parsed and validated WebAssembly module.

Enums§

Error
An error returned by the fizzyx API.
ExternKind
The kind of an imported or exported entity.
ExternType
The resolved type of an imported entity.
Mutability
The mutability of a global variable.
Val
A WebAssembly value.
ValType
A WebAssembly value type.

Constants§

DEFAULT_MEMORY_PAGES_LIMIT
The default hard limit for linear memory growth, in 64 KiB pages.
PAGE_SIZE
The size of a WebAssembly linear memory page, in bytes (64 KiB).

Type Aliases§

Result
A specialized Result type for fizzyx operations.