Skip to main content

BitReader

Struct BitReader 

Source
pub struct BitReader<'a> { /* private fields */ }
Expand description

Bit reader that reads from a byte slice.

Implementations§

Source§

impl<'a> BitReader<'a>

Source

pub fn new(data: &'a [u8]) -> Self

Create a new bit reader from a byte slice.

Source

pub fn peek_bits(&self, n: u32) -> u32

Peek at the next n bits without consuming them.

Source

pub fn read_bits(&mut self, n: u32) -> Result<u32>

Read n bits and advance the position.

Source

pub fn advance_bits(&mut self, n: u32)

Advance by n bits.

Source

pub fn read_bit(&mut self) -> Result<bool>

Read a single bit.

Source

pub fn read_byte(&mut self) -> Option<u8>

Read a single byte (8 bits).

Source

pub fn align_to_byte(&mut self)

Align to byte boundary by skipping remaining bits in current byte.

Source

pub fn bit_position(&self) -> u64

Get the current bit position.

Source

pub fn byte_position(&self) -> usize

Get the current byte position (bytes consumed from stream).

Source

pub fn is_eof(&self) -> bool

Check if at end of data.

Source

pub fn remaining_bits(&self) -> u64

Remaining bits available.

Auto Trait Implementations§

§

impl<'a> Freeze for BitReader<'a>

§

impl<'a> RefUnwindSafe for BitReader<'a>

§

impl<'a> Send for BitReader<'a>

§

impl<'a> Sync for BitReader<'a>

§

impl<'a> Unpin for BitReader<'a>

§

impl<'a> UnwindSafe for BitReader<'a>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.