pub struct Lexer<'a> { /* private fields */ }Expand description
Lexer has functionality to jump around and traverse the PDF lexemes of a string in any direction.
Implementations§
Source§impl<'a> Lexer<'a>
impl<'a> Lexer<'a>
pub fn new(buf: &'a [u8]) -> Lexer<'a>
pub fn with_offset(buf: &'a [u8], file_offset: usize) -> Lexer<'a>
Sourcepub fn next(&mut self) -> Result<Substr<'a>>
pub fn next(&mut self) -> Result<Substr<'a>>
Returns next lexeme. Lexer moves to the next byte after the lexeme. (needs to be tested)
Sourcepub fn next_stream(&mut self) -> Result<()>
pub fn next_stream(&mut self) -> Result<()>
consume the whitespace sequence following the stream start
Sourcepub fn back(&mut self) -> Result<Substr<'a>>
pub fn back(&mut self) -> Result<Substr<'a>>
Gives previous lexeme. Lexer moves to the first byte of this lexeme. (needs to be tested)
Sourcepub fn peek(&self) -> Result<Substr<'a>>
pub fn peek(&self) -> Result<Substr<'a>>
Look at the next lexeme. Will return empty substr if the next character is EOF.
Sourcepub fn next_expect(&mut self, expected: &'static str) -> Result<()>
pub fn next_expect(&mut self, expected: &'static str) -> Result<()>
Returns Ok if the next lexeme matches expected - else Err.
pub fn next_as<T>(&mut self) -> Result<T>
pub fn get_pos(&self) -> usize
pub fn new_substr(&self, range: Range<usize>) -> Substr<'a>
Sourcepub fn set_pos(&mut self, wanted_pos: usize) -> Substr<'a>
pub fn set_pos(&mut self, wanted_pos: usize) -> Substr<'a>
Just a helper function for set_pos, set_pos_from_end and offset_pos.
Sourcepub fn set_pos_from_end(&mut self, new_pos: usize) -> Substr<'a>
pub fn set_pos_from_end(&mut self, new_pos: usize) -> Substr<'a>
Returns the substr between the old and new positions
Sourcepub fn offset_pos(&mut self, offset: usize) -> Substr<'a>
pub fn offset_pos(&mut self, offset: usize) -> Substr<'a>
Returns the substr between the old and new positions
Sourcepub fn seek_newline(&mut self) -> Substr<'_>
pub fn seek_newline(&mut self) -> Substr<'_>
Moves pos to start of next line. Returns the skipped-over substring.
Sourcepub fn seek_substr(&mut self, substr: impl AsRef<[u8]>) -> Option<Substr<'a>>
pub fn seek_substr(&mut self, substr: impl AsRef<[u8]>) -> Option<Substr<'a>>
Moves pos to after the found substr. Returns Substr with traversed text if substr is found.
Sourcepub fn seek_substr_back(&mut self, substr: &[u8]) -> Result<Substr<'a>>
pub fn seek_substr_back(&mut self, substr: &[u8]) -> Result<Substr<'a>>
Searches for string backward. Moves to after the found substr, returns the traversed
Substr if found.
Sourcepub fn get_remaining_slice(&self) -> &'a [u8] ⓘ
pub fn get_remaining_slice(&self) -> &'a [u8] ⓘ
Returns slice from current position to end.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Lexer<'a>
impl<'a> RefUnwindSafe for Lexer<'a>
impl<'a> Send for Lexer<'a>
impl<'a> Sync for Lexer<'a>
impl<'a> Unpin for Lexer<'a>
impl<'a> UnwindSafe for Lexer<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more