Supporting Capability in capnproto-rust

Skip to first unread message

Troy Farrell

Aug 27, 2021, 12:38:50 AMAug 27
to Cap'n Proto
Hello everyone,

I posted a message to the Sandstorm list about trying to set a Capability field on a Params struct using capnproto-rust:

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/  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/, 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.


David Renshaw

Aug 27, 2021, 8:26:12 AMAug 27
to Troy Farrell, Cap'n Proto
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();

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:

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
To view this discussion on the web visit

Troy Farrell

Aug 27, 2021, 9:51:41 AMAug 27
to Cap'n Proto
Thanks David!  You're exactly right.  I had that staring me in the face, since (I see now that) req.get().get_cap() returns an any_pointer::Builder.

Reply all
Reply to author
0 new messages