pub trait KParser<I, O, E>where
Self: Sized,{
Show 20 methods
// Required methods
fn err_into<E2>(self) -> IntoErr<Self, O, E, E2>
where E: Into<E2>;
fn with_code<C>(self, code: C) -> WithCode<Self, C>
where C: Code,
E: KParseError<C, I>;
fn with_context<C, Y>(self, context: Y) -> WithContext<Self, C, E, Y>
where C: Code,
I: Clone,
E: Into<ParserError<C, I>>,
Y: Clone + 'static;
fn map_res<TR, O2>(self, map: TR) -> MapRes<Self, O, TR, O2>
where TR: Fn(O) -> Result<O2, Err<E>>;
fn parse_from_str<C, O2>(self, code: C) -> FromStrParser<Self, C, O, O2>
where C: Code,
O: InputIter<Item = char>,
O2: FromStr,
E: KParseError<C, I>;
fn value<O2>(self, value: O2) -> Value<Self, O, O2>
where O2: Clone;
fn all_consuming<C>(self, code: C) -> AllConsuming<Self, C>
where C: Code,
I: InputLength,
E: KParseError<C, I>;
fn complete<C>(self, code: C) -> Complete<Self, C>
where C: Code,
I: Clone,
E: KParseError<C, I>;
fn cut(self) -> Cut<Self>;
fn opt(self) -> Optional<Self>;
fn recognize(self) -> Recognize<Self, O>
where I: Clone + Slice<RangeTo<usize>> + Offset;
fn consumed(self) -> Consumed<Self>
where I: Clone + Slice<RangeTo<usize>> + Offset;
fn terminated<PA, O2>(self, terminator: PA) -> Terminated<Self, PA, O2>
where PA: Parser<I, O2, E>;
fn precedes<PA, O2>(self, successor: PA) -> Precedes<Self, PA, O>
where PA: Parser<I, O2, E>;
fn opt_precedes<PA, O2>(self, successor: PA) -> OptPrecedes<Self, PA, O>
where PA: Parser<I, O2, E>,
I: Clone;
fn delimited_by<PA, O2>(self, delimiter: PA) -> DelimitedBy<Self, PA, O2>
where PA: Parser<I, O2, E>;
fn peek(self) -> Peek<Self>
where I: Clone;
fn not<C>(self, code: C) -> PNot<Self, C, O>
where C: Code,
E: KParseError<C, I>,
I: Clone;
fn or_else<PE, OE>(self, other: PE) -> OrElse<Self, PE, OE>
where PE: Parser<I, OE, E>;
fn verify<V, C, O2>(self, verify: V, code: C) -> Verify<Self, V, C, O2>
where C: Code,
V: Fn(&O2) -> bool,
O: Borrow<O2>,
O2: ?Sized,
E: KParseError<C, I>;
}
Expand description
Adds some common parser combinators as postfix operators to parser.
Required Methods§
Sourcefn err_into<E2>(self) -> IntoErr<Self, O, E, E2>where
E: Into<E2>,
fn err_into<E2>(self) -> IntoErr<Self, O, E, E2>where
E: Into<E2>,
Converts the error to the target error.
Sourcefn with_code<C>(self, code: C) -> WithCode<Self, C>where
C: Code,
E: KParseError<C, I>,
fn with_code<C>(self, code: C) -> WithCode<Self, C>where
C: Code,
E: KParseError<C, I>,
Changes the error code.
Sourcefn with_context<C, Y>(self, context: Y) -> WithContext<Self, C, E, Y>
fn with_context<C, Y>(self, context: Y) -> WithContext<Self, C, E, Y>
Adds some context.
Sourcefn parse_from_str<C, O2>(self, code: C) -> FromStrParser<Self, C, O, O2>
fn parse_from_str<C, O2>(self, code: C) -> FromStrParser<Self, C, O, O2>
Convert the output with the FromStr trait.
Sourcefn value<O2>(self, value: O2) -> Value<Self, O, O2>where
O2: Clone,
fn value<O2>(self, value: O2) -> Value<Self, O, O2>where
O2: Clone,
Replace the output with the value.
Sourcefn all_consuming<C>(self, code: C) -> AllConsuming<Self, C>
fn all_consuming<C>(self, code: C) -> AllConsuming<Self, C>
Fails if not everything has been processed.
Sourcefn complete<C>(self, code: C) -> Complete<Self, C>
fn complete<C>(self, code: C) -> Complete<Self, C>
Converts nom::Err::Incomplete to a error code.
Sourcefn consumed(self) -> Consumed<Self>
fn consumed(self) -> Consumed<Self>
Run the parser and return the parser output and the parsed input.
Sourcefn terminated<PA, O2>(self, terminator: PA) -> Terminated<Self, PA, O2>where
PA: Parser<I, O2, E>,
fn terminated<PA, O2>(self, terminator: PA) -> Terminated<Self, PA, O2>where
PA: Parser<I, O2, E>,
Runs the parser and the terminator and just returns the result of the parser.
Sourcefn precedes<PA, O2>(self, successor: PA) -> Precedes<Self, PA, O>where
PA: Parser<I, O2, E>,
fn precedes<PA, O2>(self, successor: PA) -> Precedes<Self, PA, O>where
PA: Parser<I, O2, E>,
Runs the parser and the successor and only returns the result of the successor.
Sourcefn opt_precedes<PA, O2>(self, successor: PA) -> OptPrecedes<Self, PA, O>
fn opt_precedes<PA, O2>(self, successor: PA) -> OptPrecedes<Self, PA, O>
Runs the parser and the successor and returns the result of the successor. The parser itself may fail too.
Sourcefn delimited_by<PA, O2>(self, delimiter: PA) -> DelimitedBy<Self, PA, O2>where
PA: Parser<I, O2, E>,
fn delimited_by<PA, O2>(self, delimiter: PA) -> DelimitedBy<Self, PA, O2>where
PA: Parser<I, O2, E>,
Runs the delimiter before and after the main parser, and returns just the result of the main parser.
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.