Trait BitBuf

Source
pub trait BitBuf {
Show 13 methods // Required methods fn advance(&mut self, count: usize); fn remaining(&self) -> usize; fn chunk(&self) -> &BitSlice<u8, Msb0> ; fn chunk_bytes(&self) -> &[u8] ; fn byte_aligned(&self) -> bool; // Provided methods fn advance_bytes(&mut self, count: usize) { ... } fn remaining_bytes(&self) -> usize { ... } fn copy_to_slice(&mut self, dest: &mut BitSlice<u8, Msb0>) { ... } fn try_copy_to_slice( &mut self, dest: &mut BitSlice<u8, Msb0>, ) -> Result<(), Error> { ... } fn copy_to_slice_bytes(&mut self, dest: &mut [u8]) { ... } fn try_copy_to_slice_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { ... } fn take(self, limit: usize) -> BitTake<Self> where Self: Sized { ... } fn take_bytes(self, limit: usize) -> BitTake<Self> where Self: Sized { ... }
}

Required Methods§

Source

fn advance(&mut self, count: usize)

Advance the internal cursor of the BitBuf by count bits.

The next call to chunk() will return a slice starting count bits further into the underlying buffer.

Source

fn remaining(&self) -> usize

Returns the number of bits between the current position and the end of the buffer.

This value is greater than or equal to the length of the slice returned by chunk.

Source

fn chunk(&self) -> &BitSlice<u8, Msb0>

Returns a BitSlice starting at the current position and of length between 0 and BitBuf::remaining. Note that this can return a shorter slice.

Source

fn chunk_bytes(&self) -> &[u8]

Returns a slice of bytes starting at the current position and of length between 0 and BitBuf::remaining_bytes. Note that this can return a shorter slice.

Source

fn byte_aligned(&self) -> bool

Returns whether or not this BitBuf is fully byte-aligned (beginning and end) with the underlying storage.

Provided Methods§

Source

fn advance_bytes(&mut self, count: usize)

Advance the internal cursor of the BitBuf by count bytes.

The next call to chunk() will return a slice starting count bytes further into the underlying buffer.

Source

fn remaining_bytes(&self) -> usize

Return the number of full bytes between the current position and the end of the buffer.

Source

fn copy_to_slice(&mut self, dest: &mut BitSlice<u8, Msb0>)

Copy bits from self into dest.

The cursor is advanced by the number of bits copied. self must have enough remaining bits to fill dest.

Source

fn try_copy_to_slice( &mut self, dest: &mut BitSlice<u8, Msb0>, ) -> Result<(), Error>

Source

fn copy_to_slice_bytes(&mut self, dest: &mut [u8])

Copy bytes from self into dest. Call should call byte_aligned() beforehand to ensure buffer is fully byte-aligned before calling, call may panic if buffer isn’t byte-aligned.

The cursor is advanced by the number of bytes copied. self must have enough remaining bytes to fill dest.

Source

fn try_copy_to_slice_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>

Try to copy bytes from self into dest. Returns error if self is not big enough to fill dest or if self is not fully byte-aligned (start and end points both falling on byte boundaries).

Source

fn take(self, limit: usize) -> BitTake<Self>
where Self: Sized,

Source

fn take_bytes(self, limit: usize) -> BitTake<Self>
where Self: Sized,

Implementations on Foreign Types§

Source§

impl BitBuf for &BitSlice<u8, Msb0>

Source§

fn advance(&mut self, count: usize)

Source§

fn remaining(&self) -> usize

Source§

fn chunk(&self) -> &BitSlice<u8, Msb0>

Source§

fn chunk_bytes(&self) -> &[u8]

Source§

fn byte_aligned(&self) -> bool

Source§

impl BitBuf for &[u8]

Source§

fn advance(&mut self, count: usize)

Source§

fn remaining(&self) -> usize

Source§

fn chunk(&self) -> &BitSlice<u8, Msb0>

Source§

fn chunk_bytes(&self) -> &[u8]

Source§

fn byte_aligned(&self) -> bool

Source§

impl<T> BitBuf for &mut T
where T: BitBuf + ?Sized,

Source§

fn advance(&mut self, count: usize)

Source§

fn remaining(&self) -> usize

Source§

fn chunk(&self) -> &BitSlice<u8, Msb0>

Source§

fn chunk_bytes(&self) -> &[u8]

Source§

fn byte_aligned(&self) -> bool

Implementors§

Source§

impl BitBuf for Bits

Source§

impl BitBuf for BitsMut

Source§

impl<T> BitBuf for BitTake<T>
where T: BitBuf,

Source§

impl<T> BitBuf for BitCursor<T>
where T: AsRef<BitSlice<u8, Msb0>>,