BitStreamReader

Struct BitStreamReader 

Source
pub struct BitStreamReader<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> BitStreamReader<'a>

Source

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

Create a new LSB-first reader

§Properties
  • buffer: The buffer to read from
Source

pub fn slice(&self, from_start: bool) -> &[u8]

Return slice from reading position (or start, if from_start is true) to offset-end

Source

pub fn slice_end(&self) -> &[u8]

Return slice from offset-end to end of buffer

Source

pub fn set_crypto(&mut self, crypto: Option<Box<dyn CryptoStream>>)

Set crypto stream

Source

pub fn set_offset_end(&mut self, len: usize)

Set integrity offset to ignore when reading

Source

pub fn byte_pos(&self) -> usize

Get byte position of reader

Source

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

Read a single bit

Source

pub fn read_small(&mut self, bits: u8) -> Result<u8, DeserializationError>

Read 1-8 bits as u8 (LSB-first)

Source

pub fn read_byte(&mut self) -> Result<u8, DeserializationError>

Read a full byte, aligning to the next byte boundary

Source

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

Read a slice of bytes, aligning first

Source

pub fn read_dyn_int(&mut self) -> Result<u128, DeserializationError>

Read a dynamic int, starting at the next byte bounary The last bit is used as a continuation flag for the next byte

Source

pub fn read_fixed_int<const S: usize, T: FixedInt<S>>( &mut self, ) -> Result<T, DeserializationError>

Read a integer of fixed size from the buffer

Source

pub fn align_byte(&mut self)

Align the reader to the next byte boundary

Source

pub fn bytes_left(&self) -> usize

Get bytes left

Source

pub fn reset(&mut self)

Reset reading position

Auto Trait Implementations§

§

impl<'a> Freeze for BitStreamReader<'a>

§

impl<'a> !RefUnwindSafe for BitStreamReader<'a>

§

impl<'a> !Send for BitStreamReader<'a>

§

impl<'a> !Sync for BitStreamReader<'a>

§

impl<'a> Unpin for BitStreamReader<'a>

§

impl<'a> !UnwindSafe for BitStreamReader<'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.