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§
Sourcefn advance(&mut self, count: usize)
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.
Sourcefn remaining(&self) -> usize
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
.
Sourcefn chunk(&self) -> &BitSlice<u8, Msb0> ⓘ
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.
Sourcefn chunk_bytes(&self) -> &[u8] ⓘ
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.
Sourcefn byte_aligned(&self) -> bool
fn byte_aligned(&self) -> bool
Returns whether or not this BitBuf
is fully byte-aligned (beginning and end) with the
underlying storage.
Provided Methods§
Sourcefn advance_bytes(&mut self, count: usize)
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.
Sourcefn remaining_bytes(&self) -> usize
fn remaining_bytes(&self) -> usize
Return the number of full bytes between the current position and the end of the buffer.
Sourcefn copy_to_slice(&mut self, dest: &mut BitSlice<u8, Msb0>)
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
.
fn try_copy_to_slice( &mut self, dest: &mut BitSlice<u8, Msb0>, ) -> Result<(), Error>
Sourcefn copy_to_slice_bytes(&mut self, dest: &mut [u8])
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
.
Sourcefn try_copy_to_slice_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
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).