pub struct BitstreamWriter { /* private fields */ }Expand description
Writes individual bits or multi-bit fields into a byte buffer.
Bits are packed MSB-first within each byte. Call flush
to finalise and retrieve the completed buffer.
Implementations§
Source§impl BitstreamWriter
impl BitstreamWriter
Sourcepub fn write_bits(&mut self, value: u64, count: u8)
pub fn write_bits(&mut self, value: u64, count: u8)
Writes the lowest count bits of value, most-significant bit first.
count must be in 1..=64.
Sourcepub fn write_byte(&mut self, byte: u8)
pub fn write_byte(&mut self, byte: u8)
Writes all 8 bits of byte, MSB first.
Sourcepub fn flush(self) -> Vec<u8> ⓘ
pub fn flush(self) -> Vec<u8> ⓘ
Flushes any partially-assembled byte (zero-padded on the LSB side) and returns the completed buffer.
Sourcepub fn bits_written(&self) -> u64
pub fn bits_written(&self) -> u64
Returns the total number of bits written so far (including bits in the current partial byte).
Sourcepub fn bytes_used(&self) -> usize
pub fn bytes_used(&self) -> usize
Returns the number of complete bytes in the buffer (excluding any partial byte currently being assembled).
Trait Implementations§
Source§impl Clone for BitstreamWriter
impl Clone for BitstreamWriter
Source§fn clone(&self) -> BitstreamWriter
fn clone(&self) -> BitstreamWriter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BitstreamWriter
impl RefUnwindSafe for BitstreamWriter
impl Send for BitstreamWriter
impl Sync for BitstreamWriter
impl Unpin for BitstreamWriter
impl UnsafeUnpin for BitstreamWriter
impl UnwindSafe for BitstreamWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more