Trait kalosm_sample::Parser

source ·
pub trait Parser {
    type Error;
    type Output;
    type PartialState;

    // Required method
    fn parse<'a>(
        &self,
        state: &Self::PartialState,
        input: &'a [u8]
    ) -> Result<ParseResult<'a, Self::PartialState, Self::Output>, Self::Error>;
}
Expand description

An incremental parser for a structured input.

Required Associated Types§

source

type Error

The error type of the parser.

source

type Output

The output of the parser.

source

type PartialState

The state of the parser.

Required Methods§

source

fn parse<'a>( &self, state: &Self::PartialState, input: &'a [u8] ) -> Result<ParseResult<'a, Self::PartialState, Self::Output>, Self::Error>

Parse the given input.

Implementations on Foreign Types§

source§

impl Parser for ()

§

type Error = ()

§

type Output = ()

§

type PartialState = ()

source§

fn parse<'a>( &self, _state: &Self::PartialState, input: &'a [u8] ) -> Result<ParseResult<'a, Self::PartialState, Self::Output>, Self::Error>

source§

impl<P: ?Sized + Parser> Parser for &P

§

type Error = <P as Parser>::Error

§

type Output = <P as Parser>::Output

§

type PartialState = <P as Parser>::PartialState

source§

fn parse<'a>( &self, state: &Self::PartialState, input: &'a [u8] ) -> Result<ParseResult<'a, Self::PartialState, Self::Output>, Self::Error>

source§

impl<P: ?Sized + Parser> Parser for Box<P>

§

type Error = <P as Parser>::Error

§

type Output = <P as Parser>::Output

§

type PartialState = <P as Parser>::PartialState

source§

fn parse<'a>( &self, state: &Self::PartialState, input: &'a [u8] ) -> Result<ParseResult<'a, Self::PartialState, Self::Output>, Self::Error>

source§

impl<P: ?Sized + Parser> Parser for Arc<P>

§

type Error = <P as Parser>::Error

§

type Output = <P as Parser>::Output

§

type PartialState = <P as Parser>::PartialState

source§

fn parse<'a>( &self, state: &Self::PartialState, input: &'a [u8] ) -> Result<ParseResult<'a, Self::PartialState, Self::Output>, Self::Error>

Implementors§

source§

impl Parser for StructureParser

source§

impl Parser for ArcParser

§

type Error = Arc<dyn Error + Sync + Send>

§

type Output = Arc<dyn Any + Sync + Send>

§

type PartialState = Arc<dyn Any + Sync + Send>

source§

impl Parser for FloatParser

source§

impl Parser for I8Parser

source§

impl Parser for I16Parser

source§

impl Parser for I32Parser

source§

impl Parser for I64Parser

source§

impl Parser for IntegerParser

source§

impl Parser for RegexParser

source§

impl Parser for U8Parser

source§

impl Parser for U16Parser

source§

impl Parser for U32Parser

source§

impl Parser for U64Parser

source§

impl<E1, E2, O1, O2, PA1, PA2, P: Parser<Error = E1, Output = O1, PartialState = PA1> + CreateParserState, S: Parser<Error = E2, Output = O2, PartialState = PA2> + CreateParserState> Parser for SeparatedParser<P, S>

§

type Error = Either<E1, E2>

§

type Output = Vec<O1>

§

type PartialState = SeparatedParserState<P, S>

source§

impl<E1, E2, O1: Clone, O2, PA1, PA2, P1: Parser<Error = E1, Output = O1, PartialState = PA1>, P2: Parser<Error = E2, Output = O2, PartialState = PA2> + CreateParserState> Parser for SequenceParser<P1, P2>

§

type Error = Either<E1, E2>

§

type Output = (O1, O2)

§

type PartialState = SequenceParserState<PA1, PA2, O1>

source§

impl<E1: Clone, E2: Clone, O1, O2, PA1, PA2, P1: Parser<Error = E1, Output = O1, PartialState = PA1>, P2: Parser<Error = E2, Output = O2, PartialState = PA2>> Parser for ChoiceParser<P1, P2>

§

type Error = Either<E1, E2>

§

type Output = Either<O1, O2>

§

type PartialState = ChoiceParserState<PA1, PA2, E1, E2>

source§

impl<E, O, PA, P: Parser<Error = E, Output = O, PartialState = PA> + CreateParserState> Parser for RepeatParser<P>
where P::PartialState: Clone, P::Output: Clone,

source§

impl<F: Fn(char) -> bool + 'static> Parser for StringParser<F>

source§

impl<P: Parser, F: Fn(P::Output) -> O, O> Parser for MapOutputParser<P, F, O>

§

type Error = <P as Parser>::Error

§

type Output = O

§

type PartialState = <P as Parser>::PartialState

source§

impl<S: AsRef<str>> Parser for LiteralParser<S>

source§

impl<S: AsRef<str>, F: Fn(char) -> bool + 'static> Parser for StopOn<S, F>

source§

impl<T: HasParser> Parser for VecParser<T>

source§

impl<const MIN_LENGTH: usize, const MAX_LENGTH: usize> Parser for SentenceParser<MIN_LENGTH, MAX_LENGTH>

§

type Error = <StringParser as Parser>::Error

§

type Output = Sentence<MIN_LENGTH, MAX_LENGTH>

§

type PartialState = <StringParser as Parser>::PartialState

source§

impl<const MIN_LENGTH: usize, const MAX_LENGTH: usize> Parser for WordParser<MIN_LENGTH, MAX_LENGTH>

§

type Error = <StringParser as Parser>::Error

§

type Output = Word<MIN_LENGTH, MAX_LENGTH>

§

type PartialState = <StringParser as Parser>::PartialState

source§

impl<const N: usize, T: HasParser> Parser for ArrayParser<N, T>