Trait scan_rules::input::ScanCursor [] [src]

pub trait ScanCursor<'a>: 'a + Sized + Clone {
    type ScanInput: ScanInput<'a>;
    fn try_end(self) -> Result<(), (ScanError, Self)>;
    fn try_scan<F, Out>(self, f: F) -> Result<(Out, Self), (ScanError, Self)>
    where
        F: FnOnce(Self::ScanInput) -> Result<(Out, usize), ScanError>
; fn try_scan_raw<F, Out>(
        self,
        f: F
    ) -> Result<(Out, Self), (ScanError, Self)>
    where
        F: FnOnce(Self::ScanInput) -> Result<(Out, usize), ScanError>
; fn try_match_literal(self, lit: &str) -> Result<Self, (ScanError, Self)>; fn as_str(self) -> &'a str; fn offset(&self) -> usize; }

This trait defines the interface to input values that can be scanned.

Associated Types

Corresponding scan input type.

Required Methods

Assert that the input has been exhausted, or that the current position is a valid place to "stop".

Scan a value from the current position. The closure will be called with all available input, and is expected to return either the scanned value, and the number of bytes of input consumed, or a reason why scanning failed.

The input will have all leading whitespace removed, if applicable.

Performs the same task as try_scan, except that it does not perform whitespace stripping.

Match the provided literal term against the input.

Implementations are free to interpret "match" as they please.

Returns the remaining input as a string slice.

Returns the number of bytes consumed by this cursor since its creation.

Implementors