pub struct BitWriter { /* private fields */ }Expand description
Bit-level writer for constructing JPEG-XL bitstreams.
Writes bits in LSB-first order, accumulating a byte buffer.
Implementations§
Source§impl BitWriter
impl BitWriter
Sourcepub fn with_capacity(bytes: usize) -> Self
pub fn with_capacity(bytes: usize) -> Self
Create a new bit writer with pre-allocated capacity (in bytes).
Sourcepub fn write_bits(&mut self, value: u32, n: u8)
pub fn write_bits(&mut self, value: u32, n: u8)
Write up to 32 bits (LSB first).
Sourcepub fn write_bool(&mut self, v: bool)
pub fn write_bool(&mut self, v: bool)
Write a single boolean bit.
Sourcepub fn align_to_byte(&mut self)
pub fn align_to_byte(&mut self)
Align to the next byte boundary by writing zero bits.
Sourcepub fn finish(self) -> Vec<u8> ⓘ
pub fn finish(self) -> Vec<u8> ⓘ
Consume the writer and return the accumulated byte buffer.
Any partial byte is flushed with zero-padding.
Sourcepub fn bytes_written(&self) -> usize
pub fn bytes_written(&self) -> usize
Current number of bytes written (excluding partial byte).
Sourcepub fn bits_written(&self) -> usize
pub fn bits_written(&self) -> usize
Current total bits written.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BitWriter
impl RefUnwindSafe for BitWriter
impl Send for BitWriter
impl Sync for BitWriter
impl Unpin for BitWriter
impl UnsafeUnpin for BitWriter
impl UnwindSafe for BitWriter
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> 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