1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Safe, Wasmi/Wasmtime-inspired Rust bindings for the [WebAssembly Micro
//! Runtime (WAMR)] **fast interpreter**.
//!
//! These bindings deliberately target only WAMR's fast interpreter — no classic
//! interpreter, no AOT, and no JIT tiers — so no LLVM toolchain is required to
//! build them. Compile-time WAMR proposals map to cargo features (see the
//! crate's `Cargo.toml`).
//!
//! # Example
//!
//! ```no_run
//! use wamrx::{Engine, Linker, Module, Val};
//!
//! let engine = Engine::new()?;
//! let wasm = wat::parse_str(r#"(module (func (export "add") (param i32 i32) (result i32)
//! local.get 0 local.get 1 i32.add))"#)?;
//! let module = Module::new(&engine, &wasm)?;
//! let linker = Linker::new(&engine);
//! let instance = linker.instantiate(module)?;
//!
//! let mut results = [Val::I32(0)];
//! instance.get_func("add")?.call(&[Val::I32(2), Val::I32(3)], &mut results)?;
//! assert_eq!(results[0], Val::I32(5));
//! # Ok::<(), anyhow::Error>(())
//! ```
//!
//! # Relationship to WAMR's model
//!
//! Where WAMR's invariants differ from Wasmtime, `wamrx` surfaces them honestly
//! rather than faking them:
//!
//! - Host functions are registered in a **process-global** registry keyed by
//! module name; the [`Linker`] owns that registration.
//! - Host functions support the four numeric types and **at most one result**
//! (a limitation of WAMR's raw calling convention).
//! - A [`Module`] owns its Wasm bytes because WAMR mutates and retains the input
//! buffer.
//! - The runtime is single-threaded; [`Engine`] is neither `Send` nor `Sync`.
//!
//! [WebAssembly Micro Runtime (WAMR)]: https://github.com/bytecodealliance/wasm-micro-runtime
pub use InstanceConfig;
pub use Engine;
pub use ;
pub use Func;
pub use Global;
pub use Instance;
pub use ;
pub use Module;
pub use ;