Something like this should work:

let client: hello_capnp::hello::Client = capnp_rpc::new_client(HelloImpl);
let mut req = self.session_context.fulfill_request_request();
req.get().get_cap().set_as_capability(client.client.hook);

What'a happening here is that capnproto-rust does not have specific support
for the :Capability type, so it falls back to a general AnyPointer.

The client.client.hook thing is admittedly ugly. I think we can make that
nicer by adding an IntoInternalClientHook trait, as I commented here:
https://github.com/capnproto/capnproto-rust/issues/226#issuecomment-887604513


On Fri, Aug 27, 2021 at 12:38 AM Troy Farrell <troyjfarr...@gmail.com>
wrote:

> Hello everyone,
>
> I posted a message to the Sandstorm list about trying to set a Capability
> field on a Params struct using capnproto-rust:
> https://groups.google.com/g/sandstorm-dev/c/Mim3T5C7WUA/m/kuJcPmbZDQAJ
>
> It seems that capnproto-rust does not support Capabilities.  I would like
> to know how difficult it would be to add this support.  I have sorted out
> how to generate the set_cap() method by modifying capnproto-rust/capnpc/src/
> codegen.rs:generate_setter.  I have not sorted out what code should be
> generated and larger design questions.
>
> By design questions, I mean, for example, in capnproto-rust/capnpc/src/
> codegen_types.rs, does Capability fit as a member of pub enum Leaf?  (I
> expected to see AnyPointer there.)
>
> I am inexperienced with both Rust and Cap'n Proto and eager to understand
> both better.  Your patience is appreciated.
>
> Thanks,
> Troy
>
> --
> You received this message because you are subscribed to the Google Groups
> "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to capnproto+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/capnproto/9e911157-9dc2-4817-8824-e1482dc35746n%40googlegroups.com
> <https://groups.google.com/d/msgid/capnproto/9e911157-9dc2-4817-8824-e1482dc35746n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capnproto+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/CABR6rW-99TK8OQhHXxazh8UsS-%2B16FgoeZyggTOjy_mpMhSz3g%40mail.gmail.com.

Reply via email to