pub trait Scan<S: Scanner>: Sized {
// Required method
fn scan(scanner: &mut S) -> Result<Self, S::Error>;
}
Expand description
An extension trait to add scanning to foreign types.
This trait is generic over the specific scanner, allowing types to limit their implementation to a scanners with certain properties.
Required Methods§
sourcefn scan(scanner: &mut S) -> Result<Self, S::Error>
fn scan(scanner: &mut S) -> Result<Self, S::Error>
Reads a value from the provided scanner.
An implementation should read as many tokens as it needs from the scanner. It can assume that they are all available – the scanner will produce an error if it runs out of tokens prematurely.
The implementation does not need to keep reading until the end of tokens. It is the responsibility of the user to make sure there are no stray tokens at the end of an entry.
Finally, if an implementation needs to read tokens until the end of
the entry, it can use Scanner::continues
to check if there are
still tokens left.
If an implementation encounters an error in the presentation data,
it should report it using ScannerError::custom
unless any of the
other methods of ScannerError
seem more appropriate.