wasm3x 0.1.0

Safe, Wasmi/Wasmtime-shaped Rust bindings for the Wasm3 interpreter.
Documentation
  • Coverage
  • 100%
    44 out of 44 items documented2 out of 2 items with examples
  • Size
  • Source code size: 121.41 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.09 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • wasmi-labs/wasm3x
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Robbepop

wasm3x

Safe, wasmi/wasmtime-shaped Rust bindings for the Wasm3 WebAssembly interpreter.

The workspace has two crates:

  • wasm3x — the safe wrapper, with the familiar Engine, Store, Module, Linker, Instance, Func/TypedFunc, Memory, and Global types.
  • wasm3x-sys — raw FFI bindings. Wasm3's C sources are vendored as a git submodule; build.rs generates the bindings with bindgen and compiles a static libwasm3.a with cc.

Example

use wasm3x::{Engine, Store, Module, Linker};

let engine = Engine::default();
let mut store = Store::new(&engine, ());
let module = Module::new(&engine, &wasm_bytes)?;
let linker = Linker::<()>::new(&engine);
let instance = linker.instantiate_and_start(&mut store, &module)?;
let add = instance.get_typed_func::<(i32, i32), i32>(&store, "add")?;
assert_eq!(add.call(&mut store, (2, 3))?, 5);

Getting started

The wasm3 submodule must be checked out before the first build, and bindgen requires libclang to be installed.

git submodule update --init crates/wasm3x-sys/wasm3

cargo build
cargo test
cargo build --features wasi   # optional, self-contained WASI backend

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 Linker and linked by name.
  • Host functions are stateless and return at most one value — no Caller/&mut T access. (Wasm functions you call may still be multi-value.)
  • Validation is best-effort — Wasm3 is not a fully validating runtime.
  • Single-threadedEngine and Store are neither Send nor Sync.

License

Licensed under either of MIT or Apache-2.0 at your option. (wasm3x-sys and Wasm3 itself are MIT-licensed.)