Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created August 3, 2019 17:28
Show Gist options
  • Save rust-play/54e1251dd77bb5a221eb1765ea64a230 to your computer and use it in GitHub Desktop.
Save rust-play/54e1251dd77bb5a221eb1765ea64a230 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
struct MsgReader<'a> {
tx: &'a RoTransaction,
buf: &'a [u8];
buf_reader: BufReader<&'a [u8]>,
msg: capnp::message::Reader<'a, OwnedSegments>,
}
fn get<'a>(tx: &'a RoTransaction, id: u64) -> MsgReader<'a>
{
let buf = tx.get(id);
let buf_reader = BufReader::new(buf);
let msg = capnp::serialize::read_message(&mut buf_reader).unwrap();
MsgReader {
tx: tx,
buf: buf,
buf_reader: buf_reader,
msg: msg,
}
}
fn main() {
println!("Hello, world!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment