Trait ParserError

Source
pub trait ParserError {
    // Required methods
    fn from_parser_error<T: ?Sized + Sequence>(
        input: *const T,
        parser_type: ParserType,
    ) -> Self;
    fn from_external_error<T: ?Sized + Sequence, E: Error + Send + Sync + 'static>(
        input: *const T,
        parser_type: ParserType,
        cause: E,
    ) -> Self;

    // Provided methods
    fn add_context<T: ?Sized + Sequence>(
        &mut self,
        _input: *const T,
        _parser_type: ParserType,
    ) { ... }
    fn get_loc(&self) -> Option<usize> { ... }
}
Expand description

Trait for a parser error. This can store information about the type of parser that generated the error and its location. This is implemented by FabError and NoContextFabError.

In order to simplify lifetimes used by the error, the parser error stores a pointer to the location the error occured rather than a reference. This doesn’t require unsafe to use properly.

Required Methods§

Source

fn from_parser_error<T: ?Sized + Sequence>( input: *const T, parser_type: ParserType, ) -> Self

Source

fn from_external_error<T: ?Sized + Sequence, E: Error + Send + Sync + 'static>( input: *const T, parser_type: ParserType, cause: E, ) -> Self

Provided Methods§

Source

fn add_context<T: ?Sized + Sequence>( &mut self, _input: *const T, _parser_type: ParserType, )

Source

fn get_loc(&self) -> Option<usize>

Get the location of the error. This is used in combinators to recognize the parser that made the furthest progress.

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.

Implementors§

Source§

impl ParserError for FabError

Source§

impl ParserError for NoContextFabError

If you don’t care about the errors, and want speed, this type implements ParserError. It contains no information.