package example:myfirst@0.1.0;
world myplugin {
include wasi:cli/imports@0.2.6;
import myfirstinterface;
// export: host->guest function calls
export myfirstexport;
}
In Rust in the host, i tried linking with:
myfirstinterface::add_to_linker<MyPluginIml,HasSelf<MyPluginImpl>>(&mut linker,|f|f);
But, if I do this, then my wasm file fails to run with an error saying the imported function does not exist.
Am I supposed to do:
myplugin::add_to_linker(&mut linker,&linkeropts,|f|f);
If i have to do it this way, it means I have to implement all of the wasi:cli/imports, which is a lot of work. This makes me think there is something I am missing.
Oh, and if I have to do myfirstinterface::add_to_linker, is there a way to get wasi:cli interfaces to be part of my MyPluginImpl ? This way, I do not have to implement all the wasi interfaces.
I see that I can implement the wasi::cli::environment::Host for MyPluginImpl, but how do I get:
self.wasi_ctx.cli().get_environment()
to implement crate::host::wasi::cli::environment::Host for the world myplugin ? I get a missing trait error in Rust.
Joel has marked this topic as unresolved.
I followed the example from the bindings code hint, but am left wit this clippy error:
1. expected 3 arguments, found 2 [E0107]
2. this function takes 3 arguments but 2 arguments were supplied
argument #2 of type `&wasmtime_wasi::p2::bindings::clocks::timezone::LinkOptions` is missing [E0061]
3. expected 3 arguments, found 2 [E0107]
4. this function takes 3 arguments but 2 arguments were supplied
argument #2 of type `&wasmtime_wasi::p2::bindings::sockets::network::LinkOptions` is missing [E0061]
you can satisfy that argument with &Default::default()
when a wit contains unstable features, wit-bindgen generates a LinkOptions to enable those features, but if you don't know about then then just ignore them, the impl Default is to turn them all off
Last updated: Dec 06 2025 at 05:03 UTC