summaryrefslogtreecommitdiff
path: root/examples/linking.rs
diff options
context:
space:
mode:
authorHenry <mail@henrygressmann.de>2026-04-19 17:48:32 +0200
committerHenry <mail@henrygressmann.de>2026-04-19 17:49:59 +0200
commite667ae4554e816b4081d874fc3564b07c28dbec6 (patch)
tree534aa3b8b40eb42e77e7f4979d6fc0f3ad320c9e /examples/linking.rs
parent684d5a04a928ea4132d0c5e61bb4086fac9feb22 (diff)
feat: simplify module api
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'examples/linking.rs')
-rw-r--r--examples/linking.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/linking.rs b/examples/linking.rs
index 4da7fec..b3164ae 100644
--- a/examples/linking.rs
+++ b/examples/linking.rs
@@ -1,5 +1,5 @@
use eyre::Result;
-use tinywasm::{Module, Store};
+use tinywasm::{ModuleInstance, Store};
// WebAssembly module defining and exporting an `add` function.
const WASM_ADD: &str = r#"
@@ -27,20 +27,20 @@ fn main() -> Result<()> {
let wasm_add = wat::parse_str(WASM_ADD).expect("failed to parse wat");
let wasm_import = wat::parse_str(WASM_IMPORT).expect("failed to parse wat");
- let add_module = Module::parse_bytes(&wasm_add)?;
- let import_module = Module::parse_bytes(&wasm_import)?;
+ let add_module = tinywasm::parse_bytes(&wasm_add)?;
+ let import_module = tinywasm::parse_bytes(&wasm_import)?;
let mut store = Store::default();
// Instantiate the `add` module.
- let add_instance = add_module.instantiate(&mut store, None)?;
+ let add_instance = ModuleInstance::instantiate(&mut store, &add_module, None)?;
// Link the `adder` namespace to the `add` module's instance.
let mut imports = tinywasm::Imports::new();
imports.link_module("adder", add_instance)?;
// Instantiate the `import` module with the linked imports.
- let import_instance = import_module.instantiate(&mut store, Some(imports))?;
+ let import_instance = ModuleInstance::instantiate(&mut store, &import_module, Some(imports))?;
// Call the `main` function, which uses the imported `add` function.
let main = import_instance.func::<(), i32>(&store, "main")?;