wasm3x
Safe, wasmi/wasmtime-shaped
Rust bindings for the Wasm3 WebAssembly interpreter.
The workspace has two crates:
wasm3x— the safe wrapper, with the familiarEngine,Store,Module,Linker,Instance,Func/TypedFunc,Memory, andGlobaltypes.wasm3x-sys— raw FFI bindings. Wasm3's C sources are vendored as a git submodule;build.rsgenerates the bindings withbindgenand compiles a staticlibwasm3.awithcc.
Example
use ;
let engine = default;
let mut store = new;
let module = new?;
let linker = new;
let instance = linker.instantiate_and_start?;
let add = instance.?;
assert_eq!;
Getting started
The wasm3 submodule must be checked out before the first build, and bindgen
requires libclang to be installed.
Differences from wasmi/wasmtime
Wasm3's C-API is thinner than wasmi's, which shapes the API:
- Function lookup is runtime-global by name — no per-instance namespace and no lookup by index. This matches the common one-module-per-store usage.
- No import/export enumeration — host functions are provided through a
Linkerand linked by name. - Host functions are stateless and return at most one value — no
Caller/&mut Taccess. (Wasm functions you call may still be multi-value.) - Validation is best-effort — Wasm3 is not a fully validating runtime.
- Single-threaded —
EngineandStoreare neitherSendnorSync.
License
Licensed under either of MIT or Apache-2.0 at your
option. (wasm3x-sys and Wasm3 itself are MIT-licensed.)