pub(crate) struct Cursor<'a, T: EncodingType> {
pos: usize,
source: &'a [T::CodeUnit],
}Expand description
Cursor is a small cursor implementation for parsing Iso8601 grammar.
Fields§
§pos: usize§source: &'a [T::CodeUnit]Implementations§
Source§impl<'a, T: EncodingType> Cursor<'a, T>
impl<'a, T: EncodingType> Cursor<'a, T>
Sourcepub(crate) fn slice(
&self,
start: usize,
end: usize,
) -> Option<&'a [T::CodeUnit]>
pub(crate) fn slice( &self, start: usize, end: usize, ) -> Option<&'a [T::CodeUnit]>
Returns a string value from a slice of the cursor.
Sourcepub(crate) fn set_position(&mut self, pos: usize)
pub(crate) fn set_position(&mut self, pos: usize)
Get current position
Sourcepub(crate) fn peek(&self) -> ParserResult<Option<u8>>
pub(crate) fn peek(&self) -> ParserResult<Option<u8>>
Peek the value at next position (current + 1).
Sourcepub(crate) fn current(&self) -> ParserResult<Option<u8>>
pub(crate) fn current(&self) -> ParserResult<Option<u8>>
Returns current position in source as char.
Sourcepub(crate) fn peek_n(&self, n: usize) -> ParserResult<Option<u8>>
pub(crate) fn peek_n(&self, n: usize) -> ParserResult<Option<u8>>
Peeks the value at n as a char.
Sourcepub(crate) fn check<F>(&self, f: F) -> ParserResult<Option<bool>>
pub(crate) fn check<F>(&self, f: F) -> ParserResult<Option<bool>>
Runs the provided check on the current position.
Sourcepub(crate) fn check_or<F>(&self, default: bool, f: F) -> ParserResult<bool>
pub(crate) fn check_or<F>(&self, default: bool, f: F) -> ParserResult<bool>
Runs the provided check on current position returns the default value if None.
Sourcepub(crate) fn next(&mut self) -> ParserResult<Option<u8>>
pub(crate) fn next(&mut self) -> ParserResult<Option<u8>>
Returns Cursor’s current char and advances to the next position.
Sourcepub(crate) fn next_digit(&mut self) -> ParserResult<Option<u8>>
pub(crate) fn next_digit(&mut self) -> ParserResult<Option<u8>>
Sourcepub(crate) fn next_or(&mut self, err: ParseError) -> ParserResult<u8>
pub(crate) fn next_or(&mut self, err: ParseError) -> ParserResult<u8>
A utility next method that returns an ParseError::AbruptEnd error if invalid.
pub(crate) fn advance(&mut self)
Sourcepub(crate) fn advance_if(&mut self, condition: bool)
pub(crate) fn advance_if(&mut self, condition: bool)
Utility function to advance when a condition is true
Sourcepub(crate) fn close(&mut self) -> ParserResult<()>
pub(crate) fn close(&mut self) -> ParserResult<()>
Closes the current cursor by checking if all contents have been consumed. If not, returns an error for invalid syntax.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Cursor<'a, T>
impl<'a, T> RefUnwindSafe for Cursor<'a, T>
impl<'a, T> Send for Cursor<'a, T>
impl<'a, T> Sync for Cursor<'a, T>
impl<'a, T> Unpin for Cursor<'a, T>
impl<'a, T> UnsafeUnpin for Cursor<'a, T>
impl<'a, T> UnwindSafe for Cursor<'a, T>
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