Skip to content

Instantly share code, notes, and snippets.

@teburd
Forked from rust-play/playground.rs
Created August 3, 2019 17:32
Show Gist options
  • Save teburd/5073b540bc3eafcb08538cac268e7e1a to your computer and use it in GitHub Desktop.
Save teburd/5073b540bc3eafcb08538cac268e7e1a 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