Skip to content

Mutable methods in wit resources #178

@tqwewe

Description

@tqwewe

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions