I am trying to get a basic example up and running here: https://github.com/DougAnderson444/wit-wasm
It compiles fine, and runs fine until I try to use a host function thunk
in the guest Component fn think
at runtime I get this import error:
Error: import `mypackage:smoke/imports` has the wrong type
Caused by:
0: instance export `thunk` has the wrong type
1: expected func found nothing
Wit file:
package mypackage:smoke
interface imports {
thunk: func()
}
world smoke {
import imports
export think: func()
}
Component:
wit_bindgen::generate!("smoke" in "wit");
struct Exports;
impl Smoke for Exports {
fn think() {
mypackage::smoke::imports::thunk();
}
}
export_smoke!(Exports);
Thunk:
#[async_trait::async_trait]
impl mypackage::smoke::imports::Host for MyImports {
async fn thunk(&mut self) -> Result<()> {
self.hit = true;
println!("in the host");
Ok(())
}
}
I am using this as a guide, but maybe it's overkill? https://github.com/bytecodealliance/wasmtime/blob/afd9aced3b91ae4eab7c72e0ed4cc241ef93dc89/crates/test-programs/tests/reactor.rs
I feel like it's close! Just missing something that I'm not seeing?
@DougAnderson444 looks like you are missing adding Smoke
to the linker; i.e. Smoke::add_to_linker(&mut linker, |x| x)?;
here https://github.com/DougAnderson444/wit-wasm/blob/master/examples/smoke.rs#LL80C1-L80C1
THANK YOU @Brian You just made my day!
DougAnderson444 has marked this topic as resolved.
Last updated: Nov 22 2024 at 16:03 UTC