pub struct Bitstream<R: ReadBytes> { /* private fields */ }
Expand description
Wraps a Reader
to facilitate reading that is not byte-aligned.
Implementations§
Source§impl<R: ReadBytes> Bitstream<R>
impl<R: ReadBytes> Bitstream<R>
Sourcepub fn new(reader: R) -> Bitstream<R>
pub fn new(reader: R) -> Bitstream<R>
Wraps the reader with a reader that facilitates reading individual bits.
Sourcepub fn read_bit(&mut self) -> Result<bool>
pub fn read_bit(&mut self) -> Result<bool>
Reads a single bit.
Reading a single bit can be done more efficiently than reading more than one bit, because a bit never straddles a byte boundary.
Sourcepub fn read_unary(&mut self) -> Result<u32>
pub fn read_unary(&mut self) -> Result<u32>
Reads bits until a 1 is read, and returns the number of zeros read.
Because the reader buffers a byte internally, reading unary can be done more efficiently than by just reading bit by bit.
Sourcepub fn read_leq_u8(&mut self, bits: u32) -> Result<u8>
pub fn read_leq_u8(&mut self, bits: u32) -> Result<u8>
Reads at most eight bits.
Sourcepub fn read_gt_u8_leq_u16(&mut self, bits: u32) -> Result<u32>
pub fn read_gt_u8_leq_u16(&mut self, bits: u32) -> Result<u32>
Read n bits, where 8 < n <= 16.
Sourcepub fn read_leq_u16(&mut self, bits: u32) -> Result<u16>
pub fn read_leq_u16(&mut self, bits: u32) -> Result<u16>
Reads at most 16 bits.
Sourcepub fn read_leq_u32(&mut self, bits: u32) -> Result<u32>
pub fn read_leq_u32(&mut self, bits: u32) -> Result<u32>
Reads at most 32 bits.
Auto Trait Implementations§
impl<R> Freeze for Bitstream<R>where
R: Freeze,
impl<R> RefUnwindSafe for Bitstream<R>where
R: RefUnwindSafe,
impl<R> Send for Bitstream<R>where
R: Send,
impl<R> Sync for Bitstream<R>where
R: Sync,
impl<R> Unpin for Bitstream<R>where
R: Unpin,
impl<R> UnwindSafe for Bitstream<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more