Skip to main content

BitReader

Struct BitReader 

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

MSB-first bit reader over a byte slice.

Implementations§

Source§

impl<'a> BitReader<'a>

Source

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

Source

pub fn bit_position(&self) -> u64

Current read offset in bits, measured from the start of the input.

Source

pub fn bits_remaining(&self) -> u64

Source

pub fn is_byte_aligned(&self) -> bool

Source

pub fn align_to_byte(&mut self)

Discard bits up to the next byte boundary (§7.2 byte_aligned()).

Source

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

Read n bits (0..=32) as an unsigned integer.

Source

pub fn u1(&mut self) -> Result<u32>

Read a single bit.

Source

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

Read n bits (0..=64).

Source

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

Skip n bits.

Source

pub fn ue(&mut self) -> Result<u32>

Read a 0-th order unsigned Exp-Golomb code, ue(v) (§9.2).

Source

pub fn se(&mut self) -> Result<i32>

Read a 0-th order signed Exp-Golomb code, se(v) (§9.2.2).

Source

pub fn uek(&mut self, k: u32) -> Result<u32>

Read a k-th order unsigned Exp-Golomb code, uek(v) (§9.2 with k > 0).

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> UnsafeUnpin 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.