Skip to main content

BitReader

Struct BitReader 

Source
pub struct BitReader<'a> { /* private fields */ }
Expand description

Bit-level reader for JPEG entropy-coded data.

Handles JPEG byte-stuffing (0xFF00 → 0xFF) and marker detection. Bits are read MSB-first from a 32-bit internal buffer.

Implementations§

Source§

impl<'a> BitReader<'a>

Source

pub fn new(data: &'a [u8], pos: usize) -> Self

Create a new BitReader over the given byte slice. pos should point to the first byte of entropy-coded data (after SOS header).

Source

pub fn read_bits(&mut self, count: u8) -> Result<u16>

Read count bits (1–16) and return them right-aligned.

Source

pub fn peek_bits(&mut self, count: u8) -> Result<u16>

Peek at the top count bits without consuming them.

Source

pub fn skip_bits(&mut self, count: u8)

Discard count bits (must have been peeked already).

Source

pub fn byte_align(&mut self)

Align to the next byte boundary by discarding remaining bits in the current byte.

Source

pub fn position(&self) -> usize

Current byte position in the underlying data.

Source

pub fn marker_found(&self) -> Option<u8>

Returns the marker byte if a marker was encountered during reading.

Source

pub fn check_restart_marker(&mut self) -> Result<Option<u8>>

Check if a restart marker (0xFFD0–0xFFD7) is present. Checks both the marker_found flag (set if fill_byte already consumed a RST marker during Huffman decoding) and the next bytes in the stream. If found, consume the marker and return the marker’s low nibble (0–7).

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V