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§
sourcefn peek(&self, bits: u8) -> Option<u16>
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
.
sourcefn consume(&mut self, bits: u8) -> Result<(), Self::Error>
fn consume(&mut self, bits: u8) -> Result<(), Self::Error>
Consume the given amount of bits from the input.