Skip to main content

BitStreamWriter

Struct BitStreamWriter 

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

Implementations§

Source§

impl<'a> BitStreamWriter<'a>

Source

pub fn new(buffer: &'a mut Vec<u8>) -> Self

Create a new LSB-first writer

Source

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

Return slice of buffer

Source

pub fn set_marker(&mut self, pos: Option<usize>)

Set marker at specific position or current byte

Source

pub fn reset_marker(&mut self)

Unset marker

Source

pub fn slice_marker(&self, to: Option<usize>) -> &[u8]

Return slice from marker (or start if marker is unset) to specific position or current byte If crypto is set, it will return the unencrypted (cached) slice. This is different from other slice methods which always returns the raw buffer slice.

Source

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

Set crypto stream

Source

pub fn reset_crypto(&mut self)

Remove crypto stream

Source

pub fn byte_pos(&self) -> usize

Get byte position of writer

Source

pub fn write_bit(&mut self, val: bool)

Write a single bit

Source

pub fn write_small(&mut self, val: u8, bits: u8)

Write 1-8 bits (LSB-first)

Source

pub fn write_byte(&mut self, byte: u8)

Write a full byte, starting at the next byte boundary

Source

pub fn write_bytes(&mut self, data: &[u8])

Write a slice of bytes, starting at the next byte boundary

Source

pub fn write_dyn_int(&mut self, val: u128)

Write 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 write_fixed_int<const S: usize, T: FixedInt<S>>(&mut self, val: T)

Write a integer of fixed size to the buffer

Source

pub fn align_byte(&mut self)

Align the stream to the next byte boundary

Source

pub fn reset(&mut self)

Reset writing position

Source

pub fn len(&self) -> usize

Get buffer length

Auto Trait Implementations§

§

impl<'a> Freeze for BitStreamWriter<'a>

§

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

§

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

§

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

§

impl<'a> Unpin for BitStreamWriter<'a>

§

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