capnproto-rust
capnproto-rust copied to clipboard
Add documentation
capnproto-rust is currently impenetrable besides the examples. If one is not already familiar with using it in C++, it's very hard to "dive in".
There are examples? Seriously, I can't find any examples of even the most basic usage.
@mchaput looks like they got moved to https://github.com/dwrensha/capnpc-rust
@dwrensha Could you provide an example of deserializing a capnp message to a Rust struct? The only example in capnpc-rust is of manually extracting the fields.
There currently is no way to automatically convert between native Rust structs and Cap'n Proto messages. I discussed this a bit here.
I'm curious how one even installs capnp-rust and executes it with capnpc?
@drusellers
Step one is to make sure you have the capnp tool installed, as in: https://capnproto.org/install.html
Then the usual way to generate rust code from capnpc-rust is through a build script, as in this example. This invokes capnp compile -o - as a child process and uses the capnpc-rust crate as a library to consume the result.
Alternatively, you can use the capnpc-rust binary target. You need to give the capnp tool a way to find it; one way to do that would be to copy target/release/capnpc-rust into the same directory as the capnp tool and the capnpc-c++ and capnpc-capnp plugins -- for me that's /usr/local/bin/. Then you should be able to do capnp compile -orust foo.capnp.