Enum Err
pub enum Err<Failure, Error = Failure>
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
impl Err<(&[u8], ErrorKind)>
fn to_owned(self) -> Err<(Vec<u8>, ErrorKind)>Obtaining ownership
impl Err<(&str, ErrorKind)>
fn to_owned(self) -> Err<(String, ErrorKind)>Obtaining ownership
impl Err<Error<&[u8]>>
fn to_owned(self) -> Err<Error<Vec<u8>>>Obtaining ownership
impl Err<Error<&str>>
fn to_owned(self) -> Err<Error<String>>Obtaining ownership
impl<E> Err<E>
fn is_incomplete(&self) -> boolTests if the result is Incomplete
fn map<E2, F>(self, f: F) -> Err<E2> where F: FnOnce(E) -> E2,Applies the given function to the inner error
fn convert<F>(e: Err<F>) -> Self where E: From<F>,Automatically converts between errors if the underlying type supports it
impl<T> Err<(T, ErrorKind)>
fn map_input<U, F>(self, f: F) -> Err<(U, ErrorKind)> where F: FnOnce(T) -> U,Maps
Err<(T, ErrorKind)>toErr<(U, ErrorKind)>with the givenF: T -> U
impl<T> Err<Error<T>>
fn map_input<U, F>(self, f: F) -> Err<Error<U>> where F: FnOnce(T) -> U,Maps
Err<error::Error<T>>toErr<error::Error<U>>with the givenF: T -> U
Trait Implementations
impl<E> Display for Err<E>
where
E: Debug,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<E> Error for Err<E>
where
E: Debug,
fn source(&self) -> Option<&dyn Error + 'static>
impl<E: Eq> Eq for Err<E>
impl<Failure: Clone, Error: Clone> Clone for Err<Failure, Error>
fn clone(&self) -> Self
impl<Failure: Debug, Error: Debug> Debug for Err<Failure, Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<Failure: PartialEq, Error: PartialEq> PartialEq for Err<Failure, Error>
fn eq(&self, other: &Self) -> bool
impl<Failure: PartialEq, Error: PartialEq> StructuralPartialEq for Err<Failure, Error>
Auto Trait Implementations
impl<Failure, Error> Freeze for Err<Failure, Error>
where
Error: Freeze,
Failure: Freeze,
impl<Failure, Error> RefUnwindSafe for Err<Failure, Error>
where
Error: RefUnwindSafe,
Failure: RefUnwindSafe,
impl<Failure, Error> Send for Err<Failure, Error>
where
Error: Send,
Failure: Send,
impl<Failure, Error> Sync for Err<Failure, Error>
where
Error: Sync,
Failure: Sync,
impl<Failure, Error> Unpin for Err<Failure, Error>
where
Error: Unpin,
Failure: Unpin,
impl<Failure, Error> UnsafeUnpin for Err<Failure, Error>
where
Error: UnsafeUnpin,
Failure: UnsafeUnpin,
impl<Failure, Error> UnwindSafe for Err<Failure, Error>
where
Error: UnwindSafe,
Failure: UnwindSafe,
Blanket Implementations
impl<T> Any for Err<Failure, Error>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Err<Failure, Error>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Err<Failure, Error>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Err<Failure, Error>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Err<Failure, Error>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Err<Failure, Error>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for Err<Failure, Error>
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for Err<Failure, Error>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Err<Failure, Error>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Err<Failure, Error>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>