Trait kparse::KParseError

source ·
pub trait KParseError<C, I> {
    type WrappedError: Debug;

    // Required methods
    fn from(code: C, span: I) -> Self;
    fn with_code(self, code: C) -> Self;
    fn code(&self) -> Option<C>;
    fn span(&self) -> Option<I>;
    fn err(&self) -> Option<&Self::WrappedError>;
    fn parts(&self) -> Option<(C, I, &Self::WrappedError)>;
}
Expand description

This trait catches the essentials for an error type within this library.

It is implemented for E, nom::Err<E> and Result<(I,O), nom::Err<E>>.

Required Associated Types§

source

type WrappedError: Debug

The base error type.

Required Methods§

source

fn from(code: C, span: I) -> Self

Create a matching error.

source

fn with_code(self, code: C) -> Self

Changes the error code.

source

fn code(&self) -> Option<C>

Returns the error code if self is Result::Err and it’s not nom::Err::Incomplete.

source

fn span(&self) -> Option<I>

Returns the error span if self is Result::Err and it’s not nom::Err::Incomplete.

source

fn err(&self) -> Option<&Self::WrappedError>

Returns the error if self is Result::Err and it’s not nom::Err::Incomplete.

source

fn parts(&self) -> Option<(C, I, &Self::WrappedError)>

Returns all the parts if self is Result::Err and it’s not nom::Err::Incomplete.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<C, I> KParseError<C, I> for Err<ParserError<C, I>>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

§

type WrappedError = ParserError<C, I>

source§

fn from(code: C, span: I) -> Self

source§

fn with_code(self, code: C) -> Self

source§

fn code(&self) -> Option<C>

source§

fn span(&self) -> Option<I>

source§

fn err(&self) -> Option<&Self::WrappedError>

source§

fn parts(&self) -> Option<(C, I, &Self::WrappedError)>

source§

impl<C, I> KParseError<C, I> for Err<TokenizerError<C, I>>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

§

type WrappedError = TokenizerError<C, I>

source§

fn from(code: C, span: I) -> Self

source§

fn code(&self) -> Option<C>

source§

fn span(&self) -> Option<I>

source§

fn err(&self) -> Option<&Self::WrappedError>

source§

fn parts(&self) -> Option<(C, I, &Self::WrappedError)>

source§

fn with_code(self, code: C) -> Self

source§

impl<C, I, O> KParseError<C, I> for Result<(I, O), Err<ParserError<C, I>>>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

§

type WrappedError = ParserError<C, I>

source§

fn from(code: C, span: I) -> Self

source§

fn with_code(self, code: C) -> Self

source§

fn code(&self) -> Option<C>

source§

fn span(&self) -> Option<I>

source§

fn err(&self) -> Option<&Self::WrappedError>

source§

fn parts(&self) -> Option<(C, I, &Self::WrappedError)>

source§

impl<C, I, O> KParseError<C, I> for Result<(I, O), Err<TokenizerError<C, I>>>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

§

type WrappedError = TokenizerError<C, I>

source§

fn from(code: C, span: I) -> Self

source§

fn code(&self) -> Option<C>

source§

fn span(&self) -> Option<I>

source§

fn err(&self) -> Option<&Self::WrappedError>

source§

fn parts(&self) -> Option<(C, I, &Self::WrappedError)>

source§

fn with_code(self, code: C) -> Self

Implementors§