Skip to main content

BitInputStream

Struct BitInputStream 

Source
pub struct BitInputStream<R> { /* private fields */ }
Expand description

Big-endian bit reader backed by a byte stream.

Implementations§

Source§

impl<R: Read> BitInputStream<R>

Source

pub fn new(input: R) -> Self

Constructs a bit input stream reading big-endian bits from input.

Source

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.

Source

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.

Source

pub fn get_ref(&self) -> &R

Returns a shared reference to the underlying reader.

Source

pub fn get_mut(&mut self) -> &mut R

Returns a mutable reference to the underlying reader.

Source

pub fn into_inner(self) -> R

Consumes this stream and returns the underlying reader.

Source§

impl<R: Read + Seek> BitInputStream<R>

Source

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.

Source

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§

Source§

impl<R: Debug> Debug for BitInputStream<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.