[][src]Struct x3::bitpacker::BitPacker

pub struct BitPacker<'a> { /* fields omitted */ }

BitPacker allows individual bits to be written to an array of bytes.

Implementations

impl<'a> BitPacker<'a>[src]

pub fn new(array: &'a mut [u8]) -> BitPacker<'_>[src]

pub fn bookmark(&mut self)[src]

Save the current position as a bookmark. Later we will be able to write an array of bytes to this position.

pub fn bookmark_get_from(&self) -> &[u8][src]

Get the output array from the bookmark, to the last packed bit.

pub fn bookmark_get_offset(&self) -> usize[src]

Get number of bytes from the bookmark to the current pointer.

pub fn bookmark_write(&mut self, array: &[u8])[src]

Write the array from the bookmark onwards, until array is exhausted.

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

Standard write an array

pub fn inc_counter_n_bytes(
    &mut self,
    n_bytes: usize
) -> Result<(), BitPackError>
[src]

This operates together with write_packed_bits. It only increments the p_bit value by 1, also incrementing p_byte where necessary.

Note: The bit pointer must be byte aligned.

Arguments

  • n_bytes - The number of bytes to increment.

pub fn word_align(&mut self)[src]

Align the packing to the next word, but only if we aren't already aligned.

pub fn write_bits(&mut self, value: usize, num_bits: usize)[src]

Pack array value into the byte array. Starting at p_byte position of the array and p_bit bit offset.

Arguments

  • value - The bits that will be written.
  • num_bits - The number of bits in value that should be written.

pub fn write_packed_zeros(&mut self, num_zeros: usize)[src]

This operates together with write_packed_bits. It allows zero values to be written. Although these are never actually written to the array, the offsets are just managed.

Arguments

  • num_zeros - The number of zeros that should be written.

pub fn as_bytes(&self) -> &[u8][src]

Returns the packed bits as an array.

Auto Trait Implementations

impl<'a> RefUnwindSafe for BitPacker<'a>

impl<'a> Send for BitPacker<'a>

impl<'a> Sync for BitPacker<'a>

impl<'a> Unpin for BitPacker<'a>

impl<'a> !UnwindSafe for BitPacker<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.