Trait fax::BitReader

source ·
pub trait BitReader {
    type Error;

    // Required methods
    fn peek(&self, bits: u8) -> Option<u16>;
    fn consume(&mut self, bits: u8) -> Result<(), Self::Error>;
    fn bits_to_byte_boundary(&self) -> u8;

    // Provided method
    fn expect(&mut self, bits: Bits) -> Result<(), Option<Bits>> { ... }
}
Expand description

Trait used to read data bitwise.

For lazy people ByteReader is provided which implements this trait.

Required Associated Types§

Required Methods§

source

fn peek(&self, bits: u8) -> Option<u16>

look at the next (up to 16) bits of data

Data is returned in the lower bits of the u16.

source

fn consume(&mut self, bits: u8) -> Result<(), Self::Error>

Consume the given amount of bits from the input.

source

fn bits_to_byte_boundary(&self) -> u8

Provided Methods§

source

fn expect(&mut self, bits: Bits) -> Result<(), Option<Bits>>

Assert that the next bits matches the given pattern.

If it does not match, the found pattern is returned if enough bits are aviable. Otherwise None is returned.

Implementors§

source§

impl<E, R: Iterator<Item = Result<u8, E>>> BitReader for ByteReader<R>

§

type Error = E