Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<C, I> KParseError<C, I> for Err<ParserError<C, I>>

Source§

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>>

Source§

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>>>

Source§

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>>>

Source§

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§