Expand description
§zwasm-sdk
Rust bindings for zwasm: a small, fast, and spec-complete WebAssembly runtime written in Zig.
§Features
- Tiny and fast: ~1.2MB binary, JIT for ARM64/x86_64, full SIMD, threads, GC, exception handling, and more.
- 100% spec conformance: Passes all official Wasm spec tests and proposals through 3.0.
- Component Model: WIT parser, Canonical ABI, WASI Preview 1+2, component linking.
- Security: Deny-by-default WASI, capability flags, resource limits.
- Zero dependencies: Pure Zig core, no libc required.
- Interruption support: cancel a running invocation from another thread with
CancelHandle.
§Supported platforms
- Linux (x86_64, aarch64)
- macOS (aarch64)
§Example
use zwasm_sdk::{Module};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let wasm_bytes: &[u8] = &[
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x01, 0x60, 0x00, 0x01,
0x7f, 0x03, 0x02, 0x01, 0x00, 0x07, 0x05, 0x01, 0x01, 0x66, 0x00, 0x00, 0x0a, 0x06,
0x01, 0x04, 0x00, 0x41, 0x2a, 0x0b,
];
let module = Module::new(wasm_bytes)?;
let results = module.invoke("f", &[])?;
assert_eq!(results[0], 42);
Ok(())
}For long-running Wasm, enable cancellation in Config and use Module::cancel_handle
to interrupt an in-progress invocation from another thread. Interrupted calls can be
recognized with ZwasmError::is_interrupted.
§Design
zwasm uses a 4-tier execution pipeline:
- Bytecode → Predecoded IR → Register IR → Native JIT (ARM64/x86_64)
- All Wasm 3.0 proposals, threads, SIMD, GC, exception handling supported
- Allocator-parameterized: caller controls memory allocation
§Examples
See practical examples in the repository:
examples/run_wasm.rsexamples/host_imports.rsexamples/memory_io.rsexamples/wasi_config.rs
See the upstream README and ARCHITECTURE.md for details.
Structs§
- Cancel
Handle - A thread-safe handle that can interrupt a running Wasm invocation.
- Config
- Runtime configuration for zwasm modules.
- Imports
- Host function import registry for zwasm modules.
- Module
- Wasi
Config - WASI (WebAssembly System Interface) configuration for zwasm modules.
- Zwasm
Error