Skip to main content

RandomAccessDecoder

Struct RandomAccessDecoder 

Source
pub struct RandomAccessDecoder<D: ScanlineDecoder> { /* private fields */ }
Expand description

Random-access scanline decoder wrapper.

Wraps any ScanlineDecoder and adds get_scanline(line) support with caching and rewind logic. Ported from upstream PDFium’s ScanlineDecoder::GetScanline(int line).

Implementations§

Source§

impl<D: ScanlineDecoder> RandomAccessDecoder<D>

Source

pub fn new(inner: D) -> Self

Wrap a scanline decoder with random access capability.

Source

pub fn skip_to_scanline(&mut self, target: usize)

Skip to scanline target by warming the cache via scanline().

Overrides the sequential decode-and-discard loop from ScanlineDecoder with the random-access cache path. Mirrors PDFium’s ScanlineDecoder::SkipToScanline().

This is a Tier-1 primary: the body calls another rpdfium function (scanline()) and discards its Result return value, so it is not a pure Tier-2 delegation and must not carry #[inline].

Source

pub fn scanline(&mut self, line: usize) -> Result<Option<&[u8]>, DecodeError>

Get a specific scanline by line index (0-based).

If the requested line is the one just decoded, returns a cached copy. If the requested line is before the current position, rewinds and re-reads sequentially. Matches upstream PDFium’s caching pattern.

Primary name; get_scanline is the upstream-style alias. Mirrors PDFium’s ScanlineDecoder::GetScanline().

Source

pub fn get_scanline( &mut self, line: usize, ) -> Result<Option<&[u8]>, DecodeError>

Upstream alias for scanline(). Mirrors PDFium’s GetScanline().

Source

pub fn inner(&self) -> &D

Get a reference to the underlying decoder.

Source

pub fn width(&self) -> u32

Image width in pixels.

Source

pub fn get_width(&self) -> u32

Upstream alias for width(). Mirrors PDFium’s GetWidth().

Source

pub fn height(&self) -> u32

Image height in pixels.

Source

pub fn get_height(&self) -> u32

Upstream alias for height(). Mirrors PDFium’s GetHeight().

Source

pub fn comps_count(&self) -> u8

Number of color components per pixel. Mirrors PDFium’s CountComps().

Source

pub fn count_comps(&self) -> u8

Upstream alias for comps_count(). Mirrors PDFium’s CountComps().

Source

pub fn bpc(&self) -> u8

Bits per color component.

Source

pub fn get_bpc(&self) -> u8

Upstream alias for bpc(). Mirrors PDFium’s GetBPC().

Source

pub fn row_stride(&self) -> usize

Number of bytes per row.

Auto Trait Implementations§

§

impl<D> Freeze for RandomAccessDecoder<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for RandomAccessDecoder<D>
where D: RefUnwindSafe,

§

impl<D> Send for RandomAccessDecoder<D>
where D: Send,

§

impl<D> Sync for RandomAccessDecoder<D>
where D: Sync,

§

impl<D> Unpin for RandomAccessDecoder<D>
where D: Unpin,

§

impl<D> UnsafeUnpin for RandomAccessDecoder<D>
where D: UnsafeUnpin,

§

impl<D> UnwindSafe for RandomAccessDecoder<D>
where D: UnwindSafe,

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, 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.