capnproto-rust
capnproto-rust copied to clipboard
Implement this_client()
fixes #87.
One question though: this currently works well for a struct implementing a single interface.
If a single struct implements multiple interfaces, there will be multiple this_client implementations, one for each interface.
I'm not sure how this is going to handle multiple interfaces...
For example:
struct Calculator{}
impl calculator_add::Server for Calculator {
fn add(&mut self, params, results) {...}
}
impl calculator_sub::Server for Calculator {
fn sub(&mut self, params, results) {
let client = calculator_sub::Server::this_client(self); // Works perfectly.
let client = calculator_add::Server::this_client(self); // OUCH, we are trying to get a `calculator_add::Client` from a `calculator_sub::Client`.
}
}
If the two interfaces share the same ClientHook anyway, this is fine. Do they? Else, it's going to be a problem.
I implemented an alternative in #473.
https://github.com/capnproto/capnproto-rust/pull/595 included a simpler solution: methods get self: Rc<Self>, which can be passed to capnp_rpc::new_client_from_rc().