Trait BitBufMut

Source
pub trait BitBufMut {
Show 15 methods // Required methods fn advance_mut_bits(&mut self, count: usize); fn chunk_mut_bits(&mut self) -> &mut BitSlice<u8, Msb0> ; fn chunk_mut_bytes(&mut self) -> &mut UninitSlice; fn remaining_mut_bits(&self) -> usize; fn byte_aligned_mut(&self) -> bool; // Provided methods fn advance_mut_bytes(&mut self, count: usize) { ... } fn limit_bits(self, limit: usize) -> Limit<Self> where Self: Sized { ... } fn limit_bytes(self, limit: usize) -> Limit<Self> where Self: Sized { ... } fn has_remaining_mut_bits(&self) -> bool { ... } fn remaining_mut_bytes(&self) -> usize { ... } fn has_reminaing_mut_bytes(&self) -> bool { ... } fn chain_mut<U>(self, next: U) -> Chain<Self, U> where U: BitBufMut, Self: Sized { ... } fn put_bit_slice(&mut self, src: &BitSlice<u8, Msb0>) { ... } fn try_put_bit_slice( &mut self, src: &BitSlice<u8, Msb0>, ) -> Result<(), Error> { ... } fn try_put_slice_bytes(&mut self, src: &[u8]) -> Result<(), Error> { ... }
}

Required Methods§

Source

fn advance_mut_bits(&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.

Source

fn chunk_mut_bits(&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.

Source

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.

Source

fn remaining_mut_bits(&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.

Source

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§

Source

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.

Source

fn limit_bits(self, limit: usize) -> Limit<Self>
where Self: Sized,

Creates an adaptor which can write at most limit bits to self

Source

fn limit_bytes(self, limit: usize) -> Limit<Self>
where Self: Sized,

Creates an adaptor which can write at most limit bytes to self

Source

fn has_remaining_mut_bits(&self) -> bool

Returns true if there is space in self for more bits.

This is equivalent to calling self.remaining_mut_bits() > 0

Source

fn remaining_mut_bytes(&self) -> usize

Returns the number of full 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.

Source

fn has_reminaing_mut_bytes(&self) -> bool

Returns true if there is space in self for more bytes.

This is equivalent to calling self.remaining_mut_bytes() > 0

Source

fn chain_mut<U>(self, next: U) -> Chain<Self, U>
where U: BitBufMut, Self: Sized,

Creates an adaptor which will chain this buffer to another.

The returned BitBufMut instance will first write to all bytes from self. Afterwards it will write to next.

Source

fn put_bit_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.

Source

fn try_put_bit_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.

Source

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

Implementations on Foreign Types§

Source§

impl BitBufMut for &mut BitSlice<u8, Msb0>

Source§

impl BitBufMut for &mut [u8]

Implementors§

Source§

impl BitBufMut for BitsMut

Source§

impl<T> BitBufMut for Limit<T>
where T: BitBufMut,

Source§

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