Struct quick_protobuf::reader::Reader [] [src]

pub struct Reader { /* fields omitted */ }

A struct to read protobuf data

Contrary to BytesReader, this struct will own a buffer

Examples


// FooBar is a message generated from a proto file
// in parcicular it contains a `from_reader` function
use foo_bar::FooBar;
use quick_protobuf::Reader;

fn main() {
    // read an entire file into memory
    let mut reader = Reader::from_file("/myproject/resources/my_file.bin")
        .expect("Cannot read binary encoded file");

    // now using the generated module decoding is as easy as:
    let foobar = reader.read(FooBar::from_reader).expect("Cannot read FooBar");
    println!("Found {} foos and {} bars", foobar.foos.len(), foobar.bars.len());
}

Methods

impl Reader
[src]

Creates a new Reader

Creates a new Reader out of a file path

Run a BytesReader dependent function