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 message was moved here from #wit-bindgen > wit-bindgen-rt by Alex Crichton.
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
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: Dec 23 2024 at 12:05 UTC