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
Storetype. Methods that mutate an instance take&mut Instancedirectly. - Imports are resolved by
module::nameat instantiation time via aLinker. Only function imports are currently supported.
Structs§
- Config
- Configuration for an
Engine. - Engine
- A Fizzy engine.
- Export
Type - A description of a single module export.
- Func
- A handle to a function exported by an
Instance. - Func
Type - The signature of a function: its parameter and result types.
- Global
- A handle to a global exported by an
Instance. - Global
Type - The type of a global variable: its value type and mutability.
- Import
Type - 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. - Memory
Type - 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
fizzyxAPI. - Extern
Kind - The kind of an imported or exported entity.
- Extern
Type - 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).