Lexer

Struct Lexer 

Source
pub struct Lexer<R> { /* private fields */ }
Expand description

PDF Lexer for tokenizing PDF content

Implementations§

Source§

impl<R: Read> Lexer<R>

Source

pub fn new(reader: R) -> Self

Create a new lexer from a reader with default options

Source

pub fn new_with_options(reader: R, options: ParseOptions) -> Self

Create a new lexer from a reader with custom options

Source

pub fn warnings(&self) -> &[ParseWarning]

Get warnings collected during lexing (if enabled)

Source

pub fn next_token(&mut self) -> ParseResult<Token>

Get the next token

Source

pub fn read_newline(&mut self) -> ParseResult<()>

Read a newline sequence (CR, LF, or CRLF)

Source

pub fn peek_byte(&mut self) -> ParseResult<u8>

Read exactly n bytes Peek at the next byte without consuming it

Source

pub fn read_byte(&mut self) -> ParseResult<u8>

Read a single byte

Source

pub fn seek(&mut self, pos: u64) -> ParseResult<()>
where R: Seek,

Seek to a specific position

Source

pub fn read_bytes(&mut self, n: usize) -> ParseResult<Vec<u8>>

Source

pub fn read_until_sequence(&mut self, sequence: &[u8]) -> ParseResult<Vec<u8>>

Read until a specific byte sequence is found

Source

pub fn position(&self) -> usize

Get current position

Source

pub fn push_token(&mut self, token: Token)

Push back a token to be returned by the next call to next_token

Source

pub fn expect_keyword(&mut self, keyword: &str) -> ParseResult<()>

Expect a specific keyword token

Source

pub fn find_keyword_ahead( &mut self, keyword: &str, max_bytes: usize, ) -> ParseResult<Option<usize>>
where R: Seek,

Find a keyword ahead in the stream without consuming bytes Returns the number of bytes until the keyword is found

Source

pub fn peek_ahead(&mut self, n: usize) -> ParseResult<Vec<u8>>
where R: Seek,

Peek ahead n bytes without consuming them

Source

pub fn save_position(&mut self) -> ParseResult<(u64, Option<u8>)>
where R: Seek,

Save the current position for later restoration

Source

pub fn restore_position(&mut self, saved: (u64, Option<u8>)) -> ParseResult<()>
where R: Seek,

Restore a previously saved position

Source

pub fn peek_token(&mut self) -> ParseResult<Token>
where R: Seek,

Peek the next token without consuming it

Auto Trait Implementations§

§

impl<R> Freeze for Lexer<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Lexer<R>
where R: RefUnwindSafe,

§

impl<R> Send for Lexer<R>
where R: Send,

§

impl<R> Sync for Lexer<R>
where R: Sync,

§

impl<R> Unpin for Lexer<R>
where R: Unpin,

§

impl<R> UnwindSafe for Lexer<R>
where R: 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more