pub trait ScanCursor<'a>:
'a
+ Sized
+ Clone {
type ScanInput: ScanInput<'a>;
// Required methods
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;
}
Expand description
This trait defines the interface to input values that can be scanned.
Required Associated Types§
Required Methods§
Sourcefn try_end(self) -> Result<(), (ScanError, Self)>
fn try_end(self) -> Result<(), (ScanError, Self)>
Assert that the input has been exhausted, or that the current position is a valid place to “stop”.
Sourcefn try_scan<F, Out>(self, f: F) -> Result<(Out, Self), (ScanError, Self)>
fn try_scan<F, Out>(self, f: F) -> Result<(Out, Self), (ScanError, Self)>
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.
Sourcefn try_scan_raw<F, Out>(self, f: F) -> Result<(Out, Self), (ScanError, Self)>
fn try_scan_raw<F, Out>(self, f: F) -> Result<(Out, Self), (ScanError, Self)>
Performs the same task as try_scan
, except that it does not perform whitespace stripping.
Sourcefn try_match_literal(self, lit: &str) -> Result<Self, (ScanError, Self)>
fn try_match_literal(self, lit: &str) -> Result<Self, (ScanError, Self)>
Match the provided literal term against the input.
Implementations are free to interpret “match” as they please.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.