ReadExtTag

Trait ReadExtTag 

Source
pub trait ReadExtTag {
    // Required method
    fn read_tag(&mut self) -> Result<Option<Tag>>;
}
Expand description

Extension trait for reading tags from Read instances.

This trait provides a convenient method to read tags directly from any type that implements std::io::Read.

§Example

use ::std::io::Cursor;
use ::protobuf_core::ReadExtTag;

let data = vec![0x08]; // tag 1:0 (field 1, wire type 0)
let mut reader = Cursor::new(data);
let tag = reader.read_tag().unwrap().unwrap();
assert_eq!(tag.field_number.as_u32(), 1);

Required Methods§

Source

fn read_tag(&mut self) -> Result<Option<Tag>>

Read a tag from this reader.

Returns the Tag Ok(Some(tag)) if successfully read. Returns Ok(None) if no input is available (EOF). Returns Err(ProtobufError) if the tag is malformed.

Implementors§

Source§

impl<R> ReadExtTag for R
where R: Read,