Skip to main content

Parser

Struct Parser 

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

Recursive-descent parser over a Lexer.

Implementations§

Source§

impl<'a> Parser<'a>

Source

pub fn new(input: &'a [u8]) -> Self

Source

pub fn from_lexer(lex: Lexer<'a>) -> Self

Construct from an existing Lexer — used by the xref / trailer scanner so the same cursor state is shared.

Source

pub fn lexer_mut(&mut self) -> &mut Lexer<'a>

Borrow the underlying lexer (for seek / slice / position).

Source

pub fn position(&self) -> usize

Current byte position. Returns the start of the peeked token when one is buffered (so the position reflects “the next token’s start”, not “wherever the lexer happens to be”).

Source

pub fn parse_object(&mut self) -> Result<Option<Object>, PdfError>

Parse one Object. Returns None if the input is exhausted.

Streams encountered with an indirect /Length (a Reference value rather than a direct integer) are rejected — call Self::parse_object_with_length_resolver from a context that can resolve the reference (typically the top-level crate::reader::document::DocumentReader::resolve).

Source

pub fn parse_object_with_length_resolver( &mut self, resolver: &mut dyn LengthResolver, ) -> Result<Option<Object>, PdfError>

Variant of Self::parse_object that accepts a LengthResolver to resolve indirect /Length references on stream-object dictionaries per ISO 32000-1 §7.3.10 Example 3.

Source

pub fn parse_indirect(&mut self) -> Result<(ObjectId, Object), PdfError>

Parse one indirect object (<n> <gen> obj … endobj). Returns (ObjectId, Object). The caller is responsible for positioning the parser at the first byte of the indirect object header.

Streams with an indirect /Length are rejected — use Self::parse_indirect_with_length_resolver from a context that has a built xref table.

Source

pub fn parse_indirect_with_length_resolver( &mut self, resolver: &mut dyn LengthResolver, ) -> Result<(ObjectId, Object), PdfError>

Variant of Self::parse_indirect that accepts a LengthResolver to resolve indirect /Length references on stream-object dictionaries (ISO 32000-1 §7.3.10 Example 3).

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>

§

impl<'a> Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> UnsafeUnpin for Parser<'a>

§

impl<'a> UnwindSafe for Parser<'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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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