pub struct Lexer<R> { /* private fields */ }Expand description
PDF Lexer for tokenizing PDF content
Implementations§
Source§impl<R: Read> Lexer<R>
impl<R: Read> Lexer<R>
Sourcepub fn new_with_options(reader: R, options: ParseOptions) -> Self
pub fn new_with_options(reader: R, options: ParseOptions) -> Self
Create a new lexer from a reader with custom options
Sourcepub fn warnings(&self) -> &[ParseWarning]
pub fn warnings(&self) -> &[ParseWarning]
Get warnings collected during lexing (if enabled)
Sourcepub fn next_token(&mut self) -> ParseResult<Token>
pub fn next_token(&mut self) -> ParseResult<Token>
Get the next token
Sourcepub fn read_newline(&mut self) -> ParseResult<()>
pub fn read_newline(&mut self) -> ParseResult<()>
Read a newline sequence (CR, LF, or CRLF)
Sourcepub fn peek_byte(&mut self) -> ParseResult<u8>
pub fn peek_byte(&mut self) -> ParseResult<u8>
Read exactly n bytes Peek at the next byte without consuming it
Sourcepub fn read_byte(&mut self) -> ParseResult<u8>
pub fn read_byte(&mut self) -> ParseResult<u8>
Read a single byte
pub fn read_bytes(&mut self, n: usize) -> ParseResult<Vec<u8>>
Sourcepub fn read_until_sequence(&mut self, sequence: &[u8]) -> ParseResult<Vec<u8>>
pub fn read_until_sequence(&mut self, sequence: &[u8]) -> ParseResult<Vec<u8>>
Read until a specific byte sequence is found
Sourcepub fn push_token(&mut self, token: Token)
pub fn push_token(&mut self, token: Token)
Push back a token to be returned by the next call to next_token
Sourcepub fn expect_keyword(&mut self, keyword: &str) -> ParseResult<()>
pub fn expect_keyword(&mut self, keyword: &str) -> ParseResult<()>
Expect a specific keyword token
Sourcepub fn find_keyword_ahead(
&mut self,
keyword: &str,
max_bytes: usize,
) -> ParseResult<Option<usize>>where
R: Seek,
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
Sourcepub fn peek_ahead(&mut self, n: usize) -> ParseResult<Vec<u8>>where
R: Seek,
pub fn peek_ahead(&mut self, n: usize) -> ParseResult<Vec<u8>>where
R: Seek,
Peek ahead n bytes without consuming them
Sourcepub fn save_position(&mut self) -> ParseResult<(u64, Option<u8>)>where
R: Seek,
pub fn save_position(&mut self) -> ParseResult<(u64, Option<u8>)>where
R: Seek,
Save the current position for later restoration
Sourcepub fn restore_position(&mut self, saved: (u64, Option<u8>)) -> ParseResult<()>where
R: Seek,
pub fn restore_position(&mut self, saved: (u64, Option<u8>)) -> ParseResult<()>where
R: Seek,
Restore a previously saved position
Sourcepub fn peek_token(&mut self) -> ParseResult<Token>where
R: Seek,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more