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§
Sourcefn advance_bits(&mut self, count: usize)
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.
Sourcefn remaining_bits(&self) -> usize
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
.
Sourcefn chunk_bits(&self) -> &BitSlice<u8, Msb0> ⓘ
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.
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 has_remaining_bits(&self) -> bool
fn has_remaining_bits(&self) -> bool
Returns true if there are any more bits to consume.
This is equivalent to self.remaining_bits() > 0
Sourcefn has_remaining_bytes(&self) -> bool
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
Sourcefn chain<U>(self, next: U) -> Chain<Self, U>
fn chain<U>(self, next: U) -> Chain<Self, U>
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
.
Sourcefn copy_to_bit_slice(&mut self, dest: &mut BitSlice<u8, Msb0>)
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
.
fn try_copy_to_bit_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).
Sourcefn take_bits(self, limit: usize) -> Take<Self>where
Self: Sized,
fn take_bits(self, limit: usize) -> Take<Self>where
Self: Sized,
Create an adaptor which can read at most limit
bits from self
.
Sourcefn take_bytes(self, limit: usize) -> Take<Self>where
Self: Sized,
fn take_bytes(self, limit: usize) -> Take<Self>where
Self: Sized,
Create an adaptor which can read at most limit
bytes from self
.