Stream: wasmtime

Topic: Supply export implementation from bindgen


view this post on Zulip Trent (Dec 20 2024 at 23:41):

I'm using wasmtime with external defined/build components (still in rust), and I'm trying to implement a "context" component that they all import. The "context" component will have special access as it's defined/instantiated in the rust crate that is running the wasmtime engine.

So far things are working, however I can't find a way to use bindgen! to allow me to implement exported interfaces. I want to "host" the exported interface for the external components to use. I've resorted to manually constructing it on wasmtime::component::Linker using func_wrap etc but it's really brittle, I need to manually update the code when the "context" component wit changes.

Is there a better way to use wit/bindings to implement a privileged component? Cheers :)

view this post on Zulip Trent (Dec 21 2024 at 00:25):

Ok.. doing this allowed bindgen! to generate the Host trait and I can now implement it and everything seemingly works :) hopefully it doesn't cause something to blow up later.

world ctx {
  import program;
  export program;
}

Last updated: Dec 23 2024 at 14:03 UTC