Working with resources in WebAssembly components

⚓ Rust    📅 2025-07-11    👤 surdeus    👁️ 3      

surdeus

I read the docs in wasmtime (since I'm using that to build the host), I tried to follow the Components in Rust tutorial, but it's still not clear how to work with resources in the WebAssembly Component Model.

The spec says a resource can be in a host or a guest, yet it seems only the host owns the resource... I don't know.

A resource can have an interface, and a handle to it can be passed from one component to another, except the component that was passed the handle can't actually call the methods on it in a way that modifies the same resource. Instead, when you call resource methods from the second component it looks for the resource within its own ResourceTable and it won't match up with the handle passed in.

The point of a resource is to edit data in one component from another component to avoid copying data across WASM boundaries, but how do you actually do that?

I would have liked to peak into the Reverse Polish Notation calculator the tutorial walked through, but the code isn't in the repo with the other examples.

1 post - 1 participant

Read full topic

🏷️ rust_feed