capnproto / capnpc-rust

Cap'n Proto code generation for Rust
75 stars 26 forks source link

Add example for TypedReader #43

Closed bspeice closed 6 years ago

bspeice commented 6 years ago

Demonstrates using the TypedReader (and OwnedSegments) of capnproto/capnproto-rust#50 to communicated Cap'N Proto messages across threads.

Note: This is not safe for merge until a new runtime library is published containing the TypedReader. Code was tested against a git copy of capnproto/capnproto-rust to verify the behavior.

dwrensha commented 6 years ago

I think the instructions in the README will be no longer valid after the new binary target is added.

bspeice commented 6 years ago

For the README, you can no longer do "cargo run X" as the command. What you could do instead is:

cargo run --bin addressbook write | cargo run --bin addressbook read

Alternately, addressbook_send.rs could be moved to a different directory to preserve the easy cargo run behavior. I don't have a strong preference, but I think moving may make slightly more sense.

dwrensha commented 6 years ago

Yeah, I think moving makes more sense, unless you want to try to share code between the examples.

bspeice commented 6 years ago

Not particularly. One question on idiomatic usage - can I create a Reader<OwnedSegments> without going through the full serialization/deserialization steps?

dwrensha commented 6 years ago

Thanks!