Trait domain::base::scan::Scan

source ·
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§

source

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<S: Scanner> Scan<S> for u8

source§

fn scan(scanner: &mut S) -> Result<Self, S::Error>

source§

impl<S: Scanner> Scan<S> for u16

source§

fn scan(scanner: &mut S) -> Result<Self, S::Error>

source§

impl<S: Scanner> Scan<S> for u32

source§

fn scan(scanner: &mut S) -> Result<Self, S::Error>

source§

impl<S: Scanner> Scan<S> for u64

source§

fn scan(scanner: &mut S) -> Result<Self, S::Error>

source§

impl<S: Scanner> Scan<S> for u128

source§

fn scan(scanner: &mut S) -> Result<Self, S::Error>

Implementors§

source§

impl<S: Scanner> Scan<S> for Ttl