Trait scan_rules::scanner::ScanFromStr  
                   
                       [−]
                   
               [src]
pub trait ScanFromStr<'a>: Sized { type Output; fn scan_from<I: ScanInput<'a>>(s: I) -> Result<(Self::Output, usize), ScanError>; fn wants_leading_junk_stripped() -> bool { ... } }
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<I: ScanInput<'a>>(s: I) -> Result<(Self::Output, usize), ScanError>
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.
Provided Methods
fn wants_leading_junk_stripped() -> bool
Indicates whether or not the scanner wants its input to have leading "junk", such as whitespace, stripped.
The default implementation returns true, which is almost always the correct answer.  You should only implement this explicitly (and return false) if you are implementing a scanner for which leading whitespace is important.
Implementors
- impl<'a, K, V> ScanFromStr<'a> for BTreeMap<K, V> where K: ScanFromStr<'a, Output=K>, V: ScanFromStr<'a, Output=V>, K: Ord
- impl<'a, T> ScanFromStr<'a> for BTreeSet<T> where T: ScanFromStr<'a, Output=T>, T: Ord
- impl<'a, T> ScanFromStr<'a> for BinaryHeap<T> where T: ScanFromStr<'a, Output=T>, T: Ord
- impl<'a, K, V> ScanFromStr<'a> for HashMap<K, V> where K: ScanFromStr<'a, Output=K>, V: ScanFromStr<'a, Output=V>, K: Hash + Eq
- impl<'a, T> ScanFromStr<'a> for HashSet<T> where T: ScanFromStr<'a, Output=T>, T: Hash + Eq
- impl<'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 SocketAddrV4
- impl<'a> ScanFromStr<'a> for SocketAddrV6
- impl<'a> ScanFromStr<'a> for Ipv4Addr
- impl<'a> ScanFromStr<'a> for Ipv6Addr
- impl<'a> ScanFromStr<'a> for SocketAddr
- impl<'a> ScanFromStr<'a> for Iso8601Duration
- impl<'a, T0, T1, T2, T3> ScanFromStr<'a> for (T0, T1, T2, T3) where T0: ScanFromStr<'a>, T1: ScanFromStr<'a>, T2: ScanFromStr<'a>, T3: ScanFromStr<'a>
- impl<'a, T1, T2, T3> ScanFromStr<'a> for (T1, T2, T3) where T1: ScanFromStr<'a>, T2: ScanFromStr<'a>, T3: ScanFromStr<'a>
- impl<'a, T2, T3> ScanFromStr<'a> for (T2, T3) where T2: ScanFromStr<'a>, T3: ScanFromStr<'a>
- impl<'a, T3> ScanFromStr<'a> for (T3,) where T3: ScanFromStr<'a>
- impl<'a, T> ScanFromStr<'a> for [T; 8] where T: ScanFromStr<'a>
- impl<'a, T> ScanFromStr<'a> for [T; 7] where T: ScanFromStr<'a>
- impl<'a, T> ScanFromStr<'a> for [T; 6] where T: ScanFromStr<'a>
- impl<'a, T> ScanFromStr<'a> for [T; 5] where T: ScanFromStr<'a>
- impl<'a, T> ScanFromStr<'a> for [T; 4] where T: ScanFromStr<'a>
- impl<'a, T> ScanFromStr<'a> for [T; 3] where T: ScanFromStr<'a>
- impl<'a, T> ScanFromStr<'a> for [T; 2] where T: ScanFromStr<'a>
- impl<'a, T> ScanFromStr<'a> for [T; 1] where T: ScanFromStr<'a>
- impl<'a> ScanFromStr<'a> for ()
- impl<'a, T> ScanFromStr<'a> for [T; 0]
- impl<'a, T> ScanFromStr<'a> for Option<T> where T: ScanFromStr<'a>
- impl<'a, T, E> ScanFromStr<'a> for Result<T, E> where T: ScanFromStr<'a>, E: ScanFromStr<'a>
- impl<'a> ScanFromStr<'a> for String
- impl<'a, T> ScanFromStr<'a> for Range<T> where T: ScanFromStr<'a, Output=T>
- impl<'a, T> ScanFromStr<'a> for RangeFrom<T> where T: ScanFromStr<'a, Output=T>
- impl<'a, T> ScanFromStr<'a> for RangeTo<T> where T: ScanFromStr<'a, Output=T>
- impl<'a> ScanFromStr<'a> for RangeFull
- impl<'a> ScanFromStr<'a> for bool
- impl<'a> ScanFromStr<'a> for char
- impl<'a> ScanFromStr<'a> for f32
- impl<'a> ScanFromStr<'a> for f64
- impl<'a> ScanFromStr<'a> for i8
- impl<'a> ScanFromStr<'a> for i16
- impl<'a> ScanFromStr<'a> for i32
- impl<'a> ScanFromStr<'a> for i64
- impl<'a> ScanFromStr<'a> for isize
- impl<'a> ScanFromStr<'a> for u8
- impl<'a> ScanFromStr<'a> for u16
- impl<'a> ScanFromStr<'a> for u32
- impl<'a> ScanFromStr<'a> for u64
- impl<'a> ScanFromStr<'a> for usize
- impl<'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 HorSpace<'a, Output> where &'a str: Into<Output>
- impl<'a, Output> ScanFromStr<'a> for Ident<'a, Output> where &'a str: Into<Output>
- impl<'a, T> ScanFromStr<'a> for Inferred<T> where T: ScanSelfFromStr<'a>
- impl<'a, Output> ScanFromStr<'a> for Line<'a, Output> where &'a str: Into<Output>
- impl<'a, Output> ScanFromStr<'a> for Newline<'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 QuotedString
- impl<'a, Output> ScanFromStr<'a> for Space<'a, Output> where &'a str: Into<Output>
- impl<'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>