Enum IResult

Source
pub enum IResult<I, O, E = u32> {
    Done(I, O),
    Error(ErrorKind<E>),
    Incomplete(Needed),
}
Expand description

Holds the result of parsing functions

It depends on I, the input type, O, the output type, and E, the error type (by default u32)

Variants§

§

Done(I, O)

indicates a correct parsing, the first field containing the rest of the unparsed data, the second field contains the parsed data

§

Error(ErrorKind<E>)

contains a Err, an enum that can indicate an error code, a position in the input, and a pointer to another error, making a list of errors in the parsing tree

§

Incomplete(Needed)

Incomplete contains a Needed, an enum than can represent a known quantity of input data, or unknown

Implementations§

Source§

impl<I, O, E> IResult<I, O, E>

Source

pub fn map_err<N, F>(self, f: F) -> IResult<I, O, N>
where F: FnOnce(ErrorKind<E>) -> ErrorKind<N>,

Maps a IResult<I, O, E> to IResult<I, O, N> by appling a function to a contained Error value, leaving Done and Incomplete value untouched.

Source

pub fn unwrap_err(self) -> ErrorKind<E>

Unwrap the contained Error(E) value, or panic if the IResult is not Error.

Source

pub fn to_full_result(self) -> Result<O, IError<E>>

Convert the IResult to a std::result::Result

Source

pub fn to_result(self) -> Result<O, ErrorKind<E>>

Convert the IResult to a std::result::Result, or panic if the IResult is Incomplete

Source§

impl<I, O, E> IResult<I, O, E>

Source

pub fn is_done(&self) -> bool

Source

pub fn is_err(&self) -> bool

Source

pub fn is_incomplete(&self) -> bool

Source

pub fn or(self, other: IResult<I, O, E>) -> IResult<I, O, E>

Source

pub fn map<N, F>(self, f: F) -> IResult<I, N, E>
where F: FnOnce(O) -> N,

Maps a IResult<I, O, E> to IResult<I, N, E> by appling a function to a contained Done value, leaving Error and Incomplete value untouched.

Source

pub fn map_inc<F>(self, f: F) -> IResult<I, O, E>
where F: FnOnce(Needed) -> Needed,

Maps a IResult<I, O, E> to IResult<I, O, E> by appling a function to a contained Incomplete value, leaving Done and Error value untouched.

Source

pub fn unwrap(self) -> (I, O)

Unwrap the contained Done(I, O) value, or panic if the IResult is not Done.

Source

pub fn unwrap_inc(self) -> Needed

Unwrap the contained Incomplete(n) value, or panic if the IResult is not Incomplete.

Trait Implementations§

Source§

impl<I, O, E> Clone for IResult<I, O, E>
where I: Clone, O: Clone, E: Clone,

Source§

fn clone(&self) -> IResult<I, O, E>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I, O, E> Debug for IResult<I, O, E>
where I: Debug, O: Debug, E: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a, I, O, E> GetInput<&'a [I]> for IResult<&'a [I], O, E>

Source§

impl<'a, O, E> GetInput<&'a str> for IResult<&'a str, O, E>

Source§

impl<O, E> GetInput<()> for IResult<(), O, E>

Source§

impl<'a, I, O, E> GetOutput<&'a [O]> for IResult<I, &'a [O], E>

Source§

fn output(&self) -> Option<&'a [O]>

Source§

impl<'a, I, E> GetOutput<&'a str> for IResult<I, &'a str, E>

Source§

fn output(&self) -> Option<&'a str>

Source§

impl<I, E> GetOutput<()> for IResult<I, (), E>

Source§

fn output(&self) -> Option<()>

Source§

impl<I, O, E> PartialEq for IResult<I, O, E>
where I: PartialEq, O: PartialEq, E: PartialEq,

Source§

fn eq(&self, other: &IResult<I, O, E>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<I, O, E> Eq for IResult<I, O, E>
where I: Eq, O: Eq, E: Eq,

Source§

impl<I, O, E> StructuralPartialEq for IResult<I, O, E>

Auto Trait Implementations§

§

impl<I, O, E> Freeze for IResult<I, O, E>
where I: Freeze, O: Freeze, E: Freeze,

§

impl<I, O, E> RefUnwindSafe for IResult<I, O, E>

§

impl<I, O, E> Send for IResult<I, O, E>
where I: Send, O: Send, E: Send,

§

impl<I, O, E> Sync for IResult<I, O, E>
where I: Sync, O: Sync, E: Sync,

§

impl<I, O, E> Unpin for IResult<I, O, E>
where I: Unpin, O: Unpin, E: Unpin,

§

impl<I, O, E> UnwindSafe for IResult<I, O, E>
where I: UnwindSafe, O: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.