Trait BitBuf

Source
pub trait BitBuf {
Show 16 methods // Required methods fn advance_bits(&mut self, count: usize); fn remaining_bits(&self) -> usize; fn chunk_bits(&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 has_remaining_bits(&self) -> bool { ... } fn has_remaining_bytes(&self) -> bool { ... } fn chain<U>(self, next: U) -> Chain<Self, U> where U: BitBuf, Self: Sized { ... } fn copy_to_bit_slice(&mut self, dest: &mut BitSlice<u8, Msb0>) { ... } fn try_copy_to_bit_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_bits(self, limit: usize) -> Take<Self> where Self: Sized { ... } fn take_bytes(self, limit: usize) -> Take<Self> where Self: Sized { ... }
}

Required Methods§

Source

fn advance_bits(&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_bits(&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_bits(&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 has_remaining_bits(&self) -> bool

Returns true if there are any more bits to consume.

This is equivalent to self.remaining_bits() > 0

Source

fn has_remaining_bytes(&self) -> bool

Returns true if there are any more cmplete bytes to consume.

This is equivalent to self.remaining_bytes() > 0

Source

fn chain<U>(self, next: U) -> Chain<Self, U>
where U: BitBuf, Self: Sized,

Creates an adaptor which will chain this buffer to another.

The returned BitBuf instance will first consume all data from self. Afterwards the output is equivalent to the output of next.

Source

fn copy_to_bit_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_bit_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_bits(self, limit: usize) -> Take<Self>
where Self: Sized,

Create an adaptor which can read at most limit bits from self.

Source

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

Create an adaptor which can read at most limit bytes from self.

Implementations on Foreign Types§

Source§

impl BitBuf for &BitSlice<u8, Msb0>

Source§

impl BitBuf for &[u8]

Source§

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

Implementors§

Source§

impl BitBuf for BitCursor<&BitSlice<u8, Msb0>>

Source§

impl BitBuf for BitCursor<&[u8]>

Source§

impl BitBuf for Bits

Source§

impl BitBuf for BitsMut

Source§

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

Source§

impl<T, U> BitBuf for Chain<T, U>
where T: BitBuf, U: BitBuf,