Stream: wit-bindgen

Topic: Mutating Resources in Rust


view this post on Zulip Colin D Murphy (Nov 04 2024 at 20:23):

Is there a way for a method of a resource to mutate the resource (ie, have a &mut self parameter)?
https://component-model.bytecodealliance.org/design/wit.html#resources
It looks like the has_own_handle is a thing. Just need to figure out how to use it, but I could be way off.
https://github.com/bytecodealliance/wit-bindgen/blob/b0db20be07418e94245f2f3021859476d6c1b345/crates/core/src/types.rs#L24
There are certainly ways around this with Rust, but it would be nice to limit barriers to adoption.

A language binding generator for WebAssembly interface types - bytecodealliance/wit-bindgen

view this post on Zulip Notification Bot (Nov 04 2024 at 20:34):

A message was moved here from #wit-bindgen > wit-bindgen-rt by Alex Crichton.

view this post on Zulip Alex Crichton (Nov 04 2024 at 20:35):

Right now Rust bindings require the use of RefCell or other *Cell types for interior mutability. I've long wanted a mode where the cell is automatically used for a particular resource so you don't have to explicitly use it, but I haven't had a chance to fill that out just yet

view this post on Zulip Colin D Murphy (Nov 04 2024 at 20:37):

Yeah. I used a RefCell in my code. Maybe we just need to add an explanation to https://component-model.bytecodealliance.org/design/wit.html#resources


Last updated: Nov 22 2024 at 17:03 UTC