Skip to main content

StreamingParser

Struct StreamingParser 

Source
pub struct StreamingParser { /* private fields */ }
Expand description

Lazy file parser: reads only the xref chain eagerly, then parses individual objects on demand with windowed file reads (offsets come from the xref table). Objects — including large stream bodies — that are never requested are never loaded into RAM, unlike Parser::parse, which materializes the whole file. Each object is cached after its first read.

Implementations§

Source§

impl StreamingParser

Source

pub fn open(path: impl AsRef<Path>) -> PdfResult<Self>

Opens path and walks its xref chain. Object content is not read yet.

Source

pub fn with_parser(parser: Parser, path: impl AsRef<Path>) -> PdfResult<Self>

Opens with a configured Parser, e.g. carrying custom ParserLimits.

Source

pub fn version(&self) -> &str

PDF version from the header, e.g. "1.7".

Source

pub fn catalog(&self) -> Option<ObjectId>

Source

pub fn info(&self) -> Option<ObjectId>

Source

pub fn object_count(&self) -> usize

Number of entries in the xref table (includes free entries).

Source

pub fn file_size(&self) -> u64

Size of the backing file in bytes.

Source

pub fn get_object(&self, id: ObjectId) -> PdfResult<Option<PdfObject>>

Parses object id on demand (cached after first request). Returns Ok(None) for free or unknown entries.

Source

pub fn get_stream_data(&self, id: ObjectId) -> PdfResult<Option<Vec<u8>>>

Returns the decoded body of a stream object, or None if id is not a stream (or missing).

Auto Trait Implementations§

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.