Trait scan_rules::scanner::ScanFromStr
[−]
[src]
pub trait ScanFromStr<'a>: Sized { type Output; fn scan_from(s: &'a str) -> Result<(Self::Output, usize), ScanErrorKind>; }
This trait defines the interface to a type which can be scanned.
The exact syntax scanned is entirely arbitrary, though there are some rules of thumb that implementations should generally stick to:
- Do not ignore leading whitespace.
- Do not eagerly consume trailing whitespace, unless it is legitimately part of the scanned syntax.
In addition, if you are implementing scanning directly for the result type (i.e. Output = Self), prefer parsing only the result of the type's Debug implementation. This ensures that there is a degree of round-tripping between format! and scan!.
If a type has multiple legitimate parsing forms, consider defining those alternate forms on abstract scanner types (i.e. Output != Self) instead.
See: ScanSelfFromStr.
Associated Types
type Output
The type that the implementation scans into. This does not have to be the same as the implementing type, although it typically will be.
Required Methods
fn scan_from(s: &'a str) -> Result<(Self::Output, usize), ScanErrorKind>
Perform a scan on the given input.
Implementations must return either the scanned value, and the number of bytes consumed from the input, or a reason why scanning failed.
Implementors
impl<'a> ScanFromStr<'a> for boolimpl<'a> ScanFromStr<'a> for charimpl<'a> ScanFromStr<'a> for f32impl<'a> ScanFromStr<'a> for f64impl<'a> ScanFromStr<'a> for i8impl<'a> ScanFromStr<'a> for i16impl<'a> ScanFromStr<'a> for i32impl<'a> ScanFromStr<'a> for i64impl<'a> ScanFromStr<'a> for isizeimpl<'a> ScanFromStr<'a> for u8impl<'a> ScanFromStr<'a> for u16impl<'a> ScanFromStr<'a> for u32impl<'a> ScanFromStr<'a> for u64impl<'a> ScanFromStr<'a> for usizeimpl<'a, Output> ScanFromStr<'a> for Binary<Output> where Output: ScanFromBinary<'a>impl<'a, Output> ScanFromStr<'a> for Everything<'a, Output> where &'a str: Into<Output>impl<'a, Output> ScanFromStr<'a> for Hex<Output> where Output: ScanFromHex<'a>impl<'a, Output> ScanFromStr<'a> for Ident<'a, Output> where &'a str: Into<Output>impl<'a, Output> ScanFromStr<'a> for Line<'a, Output> where &'a str: Into<Output>impl<'a, Output> ScanFromStr<'a> for NonSpace<'a, Output> where &'a str: Into<Output>impl<'a, Output> ScanFromStr<'a> for Number<'a, Output> where &'a str: Into<Output>impl<'a, Output> ScanFromStr<'a> for Octal<Output> where Output: ScanFromOctal<'a>impl<'a, K, V> ScanFromStr<'a> for KeyValuePair<K, V> where K: ScanSelfFromStr<'a>, V: ScanSelfFromStr<'a>impl<'a> ScanFromStr<'a> for QuotedStringimpl<'a, Output> ScanFromStr<'a> for Word<'a, Output> where &'a str: Into<Output>impl<'a, Output> ScanFromStr<'a> for Wordish<'a, Output> where &'a str: Into<Output>impl<'a, K, V> ScanFromStr<'a> for BTreeMap<K, V> where K: ScanFromStr<'a, Output=K>, V: ScanFromStr<'a, Output=V>, K: Ordimpl<'a, T> ScanFromStr<'a> for BTreeSet<T> where T: ScanFromStr<'a, Output=T>, T: Ordimpl<'a, T> ScanFromStr<'a> for BinaryHeap<T> where T: ScanFromStr<'a, Output=T>, T: Ordimpl<'a, K, V> ScanFromStr<'a> for HashMap<K, V> where K: ScanFromStr<'a, Output=K>, V: ScanFromStr<'a, Output=V>, K: Hash + Eqimpl<'a, T> ScanFromStr<'a> for HashSet<T> where T: ScanFromStr<'a, Output=T>, T: Hash + Eqimpl<'a, T> ScanFromStr<'a> for LinkedList<T> where T: ScanFromStr<'a, Output=T>impl<'a, T> ScanFromStr<'a> for Vec<T> where T: ScanFromStr<'a, Output=T>impl<'a, T> ScanFromStr<'a> for VecDeque<T> where T: ScanFromStr<'a, Output=T>impl<'a> ScanFromStr<'a> for Ipv4Addrimpl<'a> ScanFromStr<'a> for Ipv6Addrimpl<'a> ScanFromStr<'a> for SocketAddrimpl<'a> ScanFromStr<'a> for SocketAddrV4impl<'a> ScanFromStr<'a> for SocketAddrV6impl<'a, T0, T1, T2, T3> ScanFromStr<'a> for (T0, T1, T2, T3) where T0: ScanSelfFromStr<'a>, T1: ScanSelfFromStr<'a>, T2: ScanSelfFromStr<'a>, T3: ScanSelfFromStr<'a>impl<'a, T1, T2, T3> ScanFromStr<'a> for (T1, T2, T3) where T1: ScanSelfFromStr<'a>, T2: ScanSelfFromStr<'a>, T3: ScanSelfFromStr<'a>impl<'a, T2, T3> ScanFromStr<'a> for (T2, T3) where T2: ScanSelfFromStr<'a>, T3: ScanSelfFromStr<'a>impl<'a, T3> ScanFromStr<'a> for (T3,) where T3: ScanSelfFromStr<'a>impl<'a, T> ScanFromStr<'a> for [T; 8] where T: ScanSelfFromStr<'a>impl<'a, T> ScanFromStr<'a> for [T; 7] where T: ScanSelfFromStr<'a>impl<'a, T> ScanFromStr<'a> for [T; 6] where T: ScanSelfFromStr<'a>impl<'a, T> ScanFromStr<'a> for [T; 5] where T: ScanSelfFromStr<'a>impl<'a, T> ScanFromStr<'a> for [T; 4] where T: ScanSelfFromStr<'a>impl<'a, T> ScanFromStr<'a> for [T; 3] where T: ScanSelfFromStr<'a>impl<'a, T> ScanFromStr<'a> for [T; 2] where T: ScanSelfFromStr<'a>impl<'a, T> ScanFromStr<'a> for [T; 1] where T: ScanSelfFromStr<'a>impl<'a> ScanFromStr<'a> for ()impl<'a, T> ScanFromStr<'a> for [T; 0]impl<'a, T> ScanFromStr<'a> for Option<T> where T: ScanSelfFromStr<'a>impl<'a, T, E> ScanFromStr<'a> for Result<T, E> where T: ScanSelfFromStr<'a>, E: ScanSelfFromStr<'a>