pub struct BitInputStream<R> { /* private fields */ }Expand description
Big-endian bit reader backed by a byte stream.
Implementations§
Source§impl<R: Read> BitInputStream<R>
impl<R: Read> BitInputStream<R>
Sourcepub fn read_bit(&mut self) -> Result<Option<u8>, ArithError>
pub fn read_bit(&mut self) -> Result<Option<u8>, ArithError>
Reads the next bit (0 or 1), or None once EOF is reached.
§Errors
Returns ArithError::Io if reading from the underlying byte stream fails.
Sourcepub fn read_bit_no_eof(&mut self) -> Result<u8, ArithError>
pub fn read_bit_no_eof(&mut self) -> Result<u8, ArithError>
Reads the next bit (0 or 1), returning ArithError::UnexpectedEof at EOF.
§Errors
Returns ArithError::UnexpectedEof at EOF or ArithError::Io on read failure.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consumes this stream and returns the underlying reader.
Source§impl<R: Read + Seek> BitInputStream<R>
impl<R: Read + Seek> BitInputStream<R>
Sourcepub fn state(&mut self) -> Result<BitInputState, ArithError>
pub fn state(&mut self) -> Result<BitInputState, ArithError>
Captures the exact stream position and buffered byte state for checkpointing.
§Errors
Returns ArithError::Io if querying the reader’s stream position fails.
Sourcepub fn restore_state(&mut self, state: BitInputState) -> Result<(), ArithError>
pub fn restore_state(&mut self, state: BitInputState) -> Result<(), ArithError>
Restores a previously captured BitInputState.
§Errors
Returns ArithError::InvalidStreamState if num_bits_remaining > 8 or
ArithError::Io if seeking fails.
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for BitInputStream<R>where
R: Freeze,
impl<R> RefUnwindSafe for BitInputStream<R>where
R: RefUnwindSafe,
impl<R> Send for BitInputStream<R>where
R: Send,
impl<R> Sync for BitInputStream<R>where
R: Sync,
impl<R> Unpin for BitInputStream<R>where
R: Unpin,
impl<R> UnsafeUnpin for BitInputStream<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for BitInputStream<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