pub enum Err<Failure, Error = Failure> {
Incomplete(Needed),
Error(Error),
Failure(Failure),
}Expand description
The Err enum indicates the parser was not successful
It has three cases:
Incompleteindicates that more data is needed to decide. TheNeededenum can contain how many additional bytes are necessary. If you are sure your parser is working on full data, you can wrap your parser with thecompletecombinator to transform that case inErrorErrormeans some parser did not succeed, but another one might (as an example, when testing different branches of analtcombinator)Failureindicates an unrecoverable error. For example, when a prefix has been recognised and the next parser has been confirmed, if that parser fails, then the entire process fails; there are no more parsers to try.
Distinguishing Failure this from Error is only relevant inside the parser’s code. For
external consumers, both mean that parsing failed.
See also: Finish.
Variants§
Incomplete(Needed)
There was not enough data
Error(Error)
The parser had an error (recoverable)
Failure(Failure)
The parser had an unrecoverable error: we got to the right branch and we know other branches won’t work, so backtrack as fast as possible
Implementations§
Source§impl<E> Err<E>
impl<E> Err<E>
Trait Implementations§
Source§impl<E> Error for Err<E>where
E: Debug,
Available on crate feature std only.
impl<E> Error for Err<E>where
E: Debug,
Available on crate feature
std only.Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
impl<E: Eq> Eq for Err<E>
impl<Failure, Error> StructuralPartialEq for Err<Failure, Error>
Auto Trait Implementations§
impl<Failure, Error> Freeze for Err<Failure, Error>
impl<Failure, Error> RefUnwindSafe for Err<Failure, Error>where
Error: RefUnwindSafe,
Failure: RefUnwindSafe,
impl<Failure, Error> Send for Err<Failure, Error>
impl<Failure, Error> Sync for Err<Failure, Error>
impl<Failure, Error> Unpin for Err<Failure, Error>
impl<Failure, Error> UnwindSafe for Err<Failure, Error>where
Error: UnwindSafe,
Failure: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more