Skip to main content

IteratorExtTag

Trait IteratorExtTag 

Source
pub trait IteratorExtTag {
    // Required methods
    fn read_tag(&mut self) -> Result<Option<Tag>>;
    fn read_tag_partial(&mut self) -> Result<Outcome>;
    fn read_tag_resume(&mut self, state: DecodeState) -> Result<Outcome>;
}
Expand description

Extension trait for reading tag from byte iterators.

This trait provides a convenient method to read tag directly from any iterator that yields bytes.

§Example

use ::protobuf_core::IteratorExtTag;

let bytes = vec![0x08]; // tag 1:0 (field 1, wire type 0)
let mut iter = bytes.into_iter();
let tag = iter.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 iterator.

Source

fn read_tag_partial(&mut self) -> Result<Outcome>

Read a tag from this iterator, supporting incomplete input.

Source

fn read_tag_resume(&mut self, state: DecodeState) -> Result<Outcome>

Resume tag decoding with additional bytes from this iterator.

Implementors§

Source§

impl<I> IteratorExtTag for I
where I: Iterator<Item = u8>,