BitPacker

Struct BitPacker 

Source
pub struct BitPacker {
    pub output: Vec<u8>,
    pub padding: u8,
    /* private fields */
}
Expand description

Creates a huffman-encoded, packed bitstream of one block of data. The final byte of the block is padded with zeros to reach a full byte. The padding is always a number between 0 and 7 inclusive.

Fields§

§output: Vec<u8>

The output buffer which can be read externally.

§padding: u8

The number of zero bits padded to the last byte of the output buffer.

Implementations§

Source§

impl BitPacker

Creates a huffman-encoded, packed bitstream of one block of data. The final byte of the block is padded with zeros to reach a full byte. The padding is always a number between 0 and 7 inclusive.

Source

pub fn new(size: usize) -> Self

Create a new BitPacker with an output buffer with the capacity specified in size.

Source

pub fn out24(&mut self, data: u32)

Writes 0-24 bits encoded with the number of bits to write in the most significant byte of a 32 bit word.

Source

pub fn out32(&mut self, data: u32)

Puts a 32 bit word of pre-packed binary encoded data on the stream.

Source

pub fn out16(&mut self, data: u16)

Puts a 16 bit word of pre-packed binary encoded data on the stream.

Source

pub fn flush(&mut self)

Flushes the remaining bits (1-7) from the buffer, padding with 0s in the least signficant bits. Flush MUST be called before reading the output or data may be left in the private queue.

Source

pub fn loc(&self) -> String

Debugging function to return the number of bytes.bits output so far

Auto Trait Implementations§

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.