capnproto-rust icon indicating copy to clipboard operation
capnproto-rust copied to clipboard

Invoking closure on the event loop to get a mutable reference to self

Open ranfdev opened this issue 2 years ago • 1 comments

Capnproto interfaces are translated to traits with methods taking &mut self. So, from my understanding, there's an event loop taking the ownership of self, which receives RPC calls and then executes the correct methods.

Can we add a way to schedule a closure on that event loop, to get access to &mut self?

Something like this:

self.dispatch(|this: &mut Self| async {});

ranfdev avatar Nov 14 '23 00:11 ranfdev

This is somewhat similar to https://github.com/capnproto/capnproto-rust/issues/87, which is about calling RPC methods on self. Off the top of my head, I'm not sure how to make all the types and traits work out, but it does seem like it should be possible.

dwrensha avatar Nov 14 '23 00:11 dwrensha