pub trait BitBufMut {
// Required methods
fn advance_mut(&mut self, count: usize);
fn chunk_mut(&mut self) -> &mut BitSlice<u8, Msb0> ⓘ;
fn chunk_mut_bytes(&mut self) -> &mut UninitSlice;
fn remaining_mut_bytes(&self) -> usize;
fn byte_aligned_mut(&self) -> bool;
// Provided methods
fn advance_mut_bytes(&mut self, count: usize) { ... }
fn remaining_mut(&self) -> usize { ... }
fn put_slice(&mut self, src: &BitSlice<u8, Msb0>) { ... }
fn try_put_slice(&mut self, src: &BitSlice<u8, Msb0>) -> Result<(), Error> { ... }
fn try_put_slice_bytes(&mut self, src: &[u8]) -> Result<(), Error> { ... }
}
Required Methods§
Sourcefn advance_mut(&mut self, count: usize)
fn advance_mut(&mut self, count: usize)
Advance the internal cursor of the BitBufMut by count
bits.
The next call to chunk_mut will return a slice starting count
bits further into the
underlying buffer.
Sourcefn chunk_mut(&mut self) -> &mut BitSlice<u8, Msb0> ⓘ
fn chunk_mut(&mut self) -> &mut BitSlice<u8, Msb0> ⓘ
Returns a mutable BitSlice
starting at the current BitBufMut
position and of length between 0
and BitBufMut::remaining_mut(). Note that this can be shorter than the whole remainder of
the buffer (this allows non-continuous implementation).
This is a lower level function. Most operations are done with other functions.
The returned byte slice may represent uninitialized memory and should not be read from.
Sourcefn chunk_mut_bytes(&mut self) -> &mut UninitSlice
fn chunk_mut_bytes(&mut self) -> &mut UninitSlice
Returns a mutable UninitSlice
starting at the current BitBufMut
position and of length between 0
and BitBufMut::remaining_mut(). Note that this can be shorter than the whole remainder of
the buffer (this allows non-continuous implementation). This BitBufMut
must be fully
byte-aligned for this to work: caller should check byte_aligned
before calling.
This is a lower level function. Most operations are done with other functions.
The returned byte slice may represent uninitialized memory and should not be read from.
Sourcefn remaining_mut_bytes(&self) -> usize
fn remaining_mut_bytes(&self) -> usize
Returns the number of bytes that can be written from the current position until the end of the buffer is reached.
This value is greater than or equal to the length of the slice returned by chunk_mut().
Writing to a BitBufMut may involve allocating more memory on the fly. Implementations may fail before reaching the number of bytes indicated by this method if they encounter an allocation failure.
Sourcefn byte_aligned_mut(&self) -> bool
fn byte_aligned_mut(&self) -> bool
Returns whether or not this BitBufMut
is fully byte-aligned (beginning and end) with the
underlying storage.
Provided Methods§
Sourcefn advance_mut_bytes(&mut self, count: usize)
fn advance_mut_bytes(&mut self, count: usize)
Advance the internal cursor of the BitBufMut by count
bytes.
The next call to chunk_mut will return a slice starting count
bytes further into the
underlying buffer.
Sourcefn remaining_mut(&self) -> usize
fn remaining_mut(&self) -> usize
Returns the number of bits that can be written from the current position until the end of
the buffer is reached. Note that the returned value may under-represent the remainin
amount: we are returning the value in bits but if the underlying storage is in bytes then
the result here will be under-represented by a factor of 8. remaining_mut_bytes
will
give a more accurate view of how much space (in bytes) is remaining.
This value is greater than or equal to the length of the slice returned by chunk_mut().
Writing to a BitBufMut may involve allocating more memory on the fly. Implementations may fail before reaching the number of bytes indicated by this method if they encounter an allocation failure.
Sourcefn put_slice(&mut self, src: &BitSlice<u8, Msb0>)
fn put_slice(&mut self, src: &BitSlice<u8, Msb0>)
Transfer bits into self
from src
and advance the cursor by the number of bits written.
self
must have enough remaining capacity to contain all of src
.
Sourcefn try_put_slice(&mut self, src: &BitSlice<u8, Msb0>) -> Result<(), Error>
fn try_put_slice(&mut self, src: &BitSlice<u8, Msb0>) -> Result<(), Error>
Try to transfer bits info self
from src
and advance the cursor by the number of bits
written.
Returns an error if self
doesn’t have enough remaining capacity to contain all of src
.