Hello,
I am having problems in passing a host function to the guest (component). Below is the wit file
default world myworld {
import foo: func(input:string) -> string
export demo: interface {
myfunction: func(input: string) -> string
}
}
how do I define and pass the "foo" function in the host to the component?
the component is created with
let component = Component::from_binary(&engine, &component)?;
let (myworld,_) = Myworld::instantiate(&mut store, &component, &linker)?;
you need to use the wasmtime::component::bindgen!
macro to generate the traits and then you need to implement those traits
it needs the component-model feature flag on wasmtime
example here https://docs.rs/wasmtime/latest/wasmtime/component/macro.bindgen.html
thanks for the link - but I am still running into issues e.g Error: module requires an import interface named env
I guess I will have to read a bit more.
(deleted)
if this is a wasi component you need the experimental host prototype from https://github.com/bytecodealliance/preview2-prototyping/tree/main/host
Ramon Klass said:
if this is a wasi component you need the experimental host prototype from https://github.com/bytecodealliance/preview2-prototyping/tree/main/host
thanks
ralph
Last updated: Dec 23 2024 at 12:05 UTC