scan_rules::scanner

Trait ScanStr

Source
pub trait ScanStr<'a>: Sized {
    type Output;

    // Required methods
    fn scan<I: ScanInput<'a>>(
        &mut self,
        s: I,
    ) -> Result<(Self::Output, usize), ScanError>;
    fn wants_leading_junk_stripped(&self) -> bool;
}
Expand description

This trait defines the interface for runtime scanners.

Runtime scanners must be created before they can be used, but this allows their behaviour to be modified at runtime.

Required Associated Types§

Source

type Output

The type that the implementation scans into.

Required Methods§

Source

fn scan<I: ScanInput<'a>>( &mut self, s: I, ) -> Result<(Self::Output, usize), ScanError>

Perform a scan on the given input.

See: ScanFromStr::scan_from.

Source

fn wants_leading_junk_stripped(&self) -> bool

Indicates whether or not the scanner wants its input to have leading “junk”, such as whitespace, stripped.

There is no default implementation of this for runtime scanners, because almost all runtime scanners forward on to some other scanner, and it is that scanner that should typically decide what to do.

Thus, in most cases, your implementation of this method should simply defer to the next scanner.

See: ScanFromStr::wants_leading_junk_stripped.

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.

Implementors§

Source§

impl<'a, S> ScanStr<'a> for ScanA<S>
where S: ScanFromStr<'a>,

Source§

type Output = <S as ScanFromStr<'a>>::Output

Source§

impl<'a, Then> ScanStr<'a> for ExactWidth<Then>
where Then: ScanStr<'a>,

Source§

type Output = <Then as ScanStr<'a>>::Output

Source§

impl<'a, Then> ScanStr<'a> for MaxWidth<Then>
where Then: ScanStr<'a>,

Source§

type Output = <Then as ScanStr<'a>>::Output

Source§

impl<'a, Then> ScanStr<'a> for MinWidth<Then>
where Then: ScanStr<'a>,

Source§

type Output = <Then as ScanStr<'a>>::Output