# wasm3x
Safe, [`wasmi`](https://docs.rs/wasmi)/[`wasmtime`](https://docs.rs/wasmtime)-shaped
Rust bindings for the [Wasm3](https://github.com/wasm3/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
```rust
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.
```sh
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-threaded** — `Engine` and `Store` are neither `Send` nor `Sync`.
## License
Licensed under either of [MIT](LICENSE-MIT) or [Apache-2.0](LICENSE-APACHE) at your
option. (`wasm3x-sys` and Wasm3 itself are MIT-licensed.)