Skip to main content

BitReader

Struct BitReader 

Source
pub struct BitReader<R: Read, E: Endianness> { /* private fields */ }

Implementations§

Source§

impl<R: Read, E: Endianness> BitReader<R, E>

Source

pub fn new(reader: R) -> Self

Create a new BitReader wrapping the given reader

Source

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

Reads a single bit from the stream

Source

pub fn read<const BITS: u32, T: Integer>(&mut self) -> Result<T>

Reads up to BITS bits as a value of type T

Source

pub fn read_var<T: Integer>(&mut self, bits: u32) -> Result<T>

Reads bits number of bits as a value of type T

Source

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

Skips the given number of bits

Source

pub fn byte_aligned(&self) -> bool

Returns true if the stream is byte-aligned

Source

pub fn byte_align(&mut self)

Discards any remaining bits until the stream is byte-aligned

Source

pub fn read_bytes(&mut self, buf: &mut [u8]) -> Result<()>

Reads exactly buf.len() bytes into the buffer

Source

pub fn read_to_vec(&mut self, bytes: usize) -> Result<Vec<u8>>

Reads bytes number of bytes into a vector

Source

pub fn read_unary<const STOP_BIT: u8>(&mut self) -> Result<u32>

Reads bits until a stop bit is encountered

Source§

impl<R: Read + Seek, E: Endianness> BitReader<R, E>

Source

pub fn bits_left(&mut self) -> Result<usize>

Returns the number of bits left in the stream

Source§

impl<'a, E: Endianness> BitReader<Cursor<&'a [u8]>, E>

Source

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

Create a BitReader from a byte slice, automatically tracking length

Source

pub fn remaining_slice(&mut self) -> &'a [u8]

Get the remaining data as a byte-aligned slice

Source§

impl<R: Read> BitReader<R, BigEndian>

Source

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

Reads an unsigned Exp-Golomb coded value (ue(v))

Source

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

Reads a signed Exp-Golomb coded value (se(v))

Source§

impl<R: Read + Seek, E: Endianness> BitReader<R, E>

Source

pub fn position_in_bits(&mut self) -> Result<u64>

Gets the current position in bits from the start of the stream

Source

pub fn seek_bits(&mut self, from: SeekFrom) -> Result<u64>

Seeks to a position in the stream by bits

Source

pub fn peek<const BITS: u32, T: Integer>(&mut self) -> Result<T>

Peeks the next BITS bits without consuming them

Source

pub fn peek_var<T: Integer>(&mut self, bits: u32) -> Result<T>

Peeks bits number of bits without consuming them

Source

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

Peeks a single bit without consuming it

Source§

impl<R: Read + Seek> BitReader<R, BigEndian>

Source

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

Peeks an unsigned Exp-Golomb coded value without consuming it

Source

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

Peeks a signed Exp-Golomb coded value without consuming it

Auto Trait Implementations§

§

impl<R, E> Freeze for BitReader<R, E>
where R: Freeze,

§

impl<R, E> RefUnwindSafe for BitReader<R, E>

§

impl<R, E> Send for BitReader<R, E>
where R: Send, E: Send,

§

impl<R, E> Sync for BitReader<R, E>
where R: Sync, E: Sync,

§

impl<R, E> Unpin for BitReader<R, E>
where R: Unpin, E: Unpin,

§

impl<R, E> UnsafeUnpin for BitReader<R, E>
where R: UnsafeUnpin,

§

impl<R, E> UnwindSafe for BitReader<R, E>
where R: UnwindSafe, E: 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 = 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.