Paul Colomiets said:
You can use
resource
to keep state: https://github.com/bytecodealliance/wit-bindgen/blob/main/WIT.md#item-resource (or just use global/static variables in Rust).
I'm looking into using resources with the following .wit file:
resource aggregate {
static new: function(id: string) -> aggregate
apply-events: function(event: list<list<u8>>)
}
Which generates:
pub trait Aggregate {
fn new(id: String,) -> wit_bindgen_rust::Handle<super::Aggregate>;
fn apply_events(&self,event: Vec<Vec<u8>>,);
}
But using the online demo to see the generated rust code for export, the apply-events
method takes &self
. But what if I want to mutate self with &mut self
? Is this possible?
I've made a GH issue for it here:
https://github.com/bytecodealliance/wit-bindgen/issues/178
Ari Seyhun has marked this topic as resolved.
Last updated: Nov 22 2024 at 17:03 UTC