pub struct BitReader<'a> { /* private fields */ }Expand description
Bit-level reader for parsing JPEG-XL bitstreams.
Reads bits from a byte buffer in LSB-first order, which is the convention used by JPEG-XL codestreams (and ANS entropy coding).
Implementations§
Source§impl<'a> BitReader<'a>
impl<'a> BitReader<'a>
Sourcepub fn read_bits(&mut self, n: u8) -> CodecResult<u32>
pub fn read_bits(&mut self, n: u8) -> CodecResult<u32>
Read up to 32 bits from the stream (LSB first).
§Errors
Returns CodecError::InvalidBitstream if not enough bits remain.
Sourcepub fn read_bool(&mut self) -> CodecResult<bool>
pub fn read_bool(&mut self) -> CodecResult<bool>
Read a single boolean bit.
Sourcepub fn read_u8(&mut self, n: u8) -> CodecResult<u8>
pub fn read_u8(&mut self, n: u8) -> CodecResult<u8>
Read up to 8 bits as a u8.
Sourcepub fn read_u16(&mut self, n: u8) -> CodecResult<u16>
pub fn read_u16(&mut self, n: u8) -> CodecResult<u16>
Read up to 16 bits as a u16.
Sourcepub fn read_u32(&mut self, n: u8) -> CodecResult<u32>
pub fn read_u32(&mut self, n: u8) -> CodecResult<u32>
Read up to 32 bits as a u32.
Sourcepub fn read_u64(&mut self) -> CodecResult<u64>
pub fn read_u64(&mut self) -> CodecResult<u64>
Read a u64 value using JPEG-XL’s U64 encoding.
The JXL U64 encoding uses a selector to determine how many bits follow:
- 0: value = 0
- 1: value = 1 + read(4)
- 2: value = 17 + read(8)
- 3: value = read(12) + (read variable chunks until done)
Sourcepub fn remaining_bits(&self) -> usize
pub fn remaining_bits(&self) -> usize
Number of bits remaining in the stream.
Sourcepub fn align_to_byte(&mut self)
pub fn align_to_byte(&mut self)
Align the reader to the next byte boundary.
If already at a byte boundary, this is a no-op.
Sourcepub fn byte_position(&self) -> usize
pub fn byte_position(&self) -> usize
Get current byte position.
Auto Trait Implementations§
impl<'a> Freeze for BitReader<'a>
impl<'a> RefUnwindSafe for BitReader<'a>
impl<'a> Send for BitReader<'a>
impl<'a> Sync for BitReader<'a>
impl<'a> Unpin for BitReader<'a>
impl<'a> UnsafeUnpin for BitReader<'a>
impl<'a> UnwindSafe for BitReader<'a>
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