zune_inflate::bitstream

Struct BitStreamReader

source
pub struct BitStreamReader<'src> {
    pub src: &'src [u8],
    pub position: usize,
    pub bits_left: u8,
    pub buffer: u64,
    pub over_read: usize,
}

Fields§

§src: &'src [u8]§position: usize§bits_left: u8§buffer: u64§over_read: usize

Implementations§

source§

impl<'src> BitStreamReader<'src>

source

pub fn new(in_buffer: &'src [u8]) -> BitStreamReader<'src>

Create a new BitStreamReader instance

§Expectations

The buffer must be padded with fill bytes in the end, if not, this becomes UB in the refill phase.

source

pub fn refill(&mut self)

Refill the bitstream ensuring the buffer has bits between 56 and 63.

source

pub fn refill_inner_loop(&mut self)

source

fn refill_slow(&mut self)

source

pub fn peek_bits<const LOOKAHEAD: usize>(&self) -> usize

source

pub fn peek_var_bits(&self, lookahead: usize) -> usize

source

pub fn get_bits(&mut self, num_bits: u8) -> u64

source

pub const fn get_bits_left(&self) -> u8

Get number of bits left in the bit buffer.

source

pub fn get_position(&self) -> usize

Get position the stream is in this buffer Or alternatively, number of bits read.

source

pub fn reset(&mut self)

Reset buffer and bits left to zero.

source

pub const fn has(&self, bits: u8) -> bool

Return true if the bit buffer can satisfy bits read without refilling,

source

pub fn drop_bits(&mut self, bits: u8)

source

pub const fn remaining_bytes(&self) -> usize

Return the remaining bytes in this stream.

This does not consider bits in the bit-buffer hence may not be accurate

Auto Trait Implementations§

§

impl<'src> Freeze for BitStreamReader<'src>

§

impl<'src> RefUnwindSafe for BitStreamReader<'src>

§

impl<'src> Send for BitStreamReader<'src>

§

impl<'src> Sync for BitStreamReader<'src>

§

impl<'src> Unpin for BitStreamReader<'src>

§

impl<'src> UnwindSafe for BitStreamReader<'src>

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.