Skip to content

Commit d4b8cfc

Browse files
committed
feat(wit+broker): add world export start() and invoke it after component instantiation
1 parent e17378e commit d4b8cfc

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

crates/broker/src/wasmtime_host.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,18 @@ mod impls {
123123
.map_err(|e| e.to_string())?;
124124

125125
// Instantiate component
126-
let (_instance, _exports) = bindings::App::instantiate(&mut store, &component, &linker)
126+
let (exports, _instance) = bindings::App::instantiate(&mut store, &component, &linker)
127127
.map_err(|e| e.to_string())?;
128128

129-
// If the world exports entry functions, call them here (not defined yet).
130-
Ok(())
129+
// Call exported start function
130+
match exports.call_start(&mut store) {
131+
Ok(s) => {
132+
// Print or log the returned string for demo
133+
println!("component.start: {s}");
134+
Ok(())
135+
}
136+
Err(e) => Err(e.to_string()),
137+
}
131138
}
132139
}
133140

crates/wit/world.wit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ world app {
2929
import log;
3030
import time;
3131
import rand;
32+
33+
// Minimal exported entry for exercising the component.
34+
export start: func() -> string;
3235
}

0 commit comments

Comments
 (0)