pub struct StringParser<F: Fn(char) -> bool + 'static = fn(char) -> bool> { /* private fields */ }Expand description
A parser for an ascii string.
Implementations§
Source§impl StringParser<fn(char) -> bool>
impl StringParser<fn(char) -> bool>
Sourcepub fn new(len_range: RangeInclusive<usize>) -> Self
pub fn new(len_range: RangeInclusive<usize>) -> Self
Create a new string parser.
Source§impl<F: Fn(char) -> bool + 'static> StringParser<F>
impl<F: Fn(char) -> bool + 'static> StringParser<F>
Sourcepub fn with_allowed_characters<F2: Fn(char) -> bool + 'static>(
self,
character_filter: F2,
) -> StringParser<F2>
pub fn with_allowed_characters<F2: Fn(char) -> bool + 'static>( self, character_filter: F2, ) -> StringParser<F2>
Only allow characters that pass the filter.
Sourcepub fn plain_text(self) -> StringParser
pub fn plain_text(self) -> StringParser
Only parse plain text that matches the character filter ‘a’..‘z’ | ‘A’..‘Z’ | ‘0’..‘9’ | ’ ’ | ‘,’ | ‘.’
Sourcepub fn alphanumeric_with_spaces(self) -> StringParser
pub fn alphanumeric_with_spaces(self) -> StringParser
Only parse alphanumeric text and spaces (the character filter ‘a’..‘z’ | ‘A’..‘Z’ | ‘0’..‘9’ | ’ ’)
Trait Implementations§
Source§impl<F: Clone + Fn(char) -> bool + 'static> Clone for StringParser<F>
impl<F: Clone + Fn(char) -> bool + 'static> Clone for StringParser<F>
Source§fn clone(&self) -> StringParser<F>
fn clone(&self) -> StringParser<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F: Fn(char) -> bool + 'static> CreateParserState for StringParser<F>
impl<F: Fn(char) -> bool + 'static> CreateParserState for StringParser<F>
Source§fn create_parser_state(&self) -> <Self as Parser>::PartialState
fn create_parser_state(&self) -> <Self as Parser>::PartialState
Create the default state of the parser.
Source§impl<F: Fn(char) -> bool + 'static> Parser for StringParser<F>
impl<F: Fn(char) -> bool + 'static> Parser for StringParser<F>
Source§type PartialState = StringParserState
type PartialState = StringParserState
The state of the parser.
Source§fn parse<'a>(
&self,
state: &StringParserState,
input: &'a [u8],
) -> ParseResult<ParseStatus<'a, Self::PartialState, Self::Output>>
fn parse<'a>( &self, state: &StringParserState, input: &'a [u8], ) -> ParseResult<ParseStatus<'a, Self::PartialState, Self::Output>>
Parse the given input.
impl<F: Eq + Fn(char) -> bool + 'static> Eq for StringParser<F>
impl<F: Fn(char) -> bool + 'static> StructuralPartialEq for StringParser<F>
Auto Trait Implementations§
impl<F> Freeze for StringParser<F>where
F: Freeze,
impl<F> RefUnwindSafe for StringParser<F>where
F: RefUnwindSafe,
impl<F> Send for StringParser<F>where
F: Send,
impl<F> Sync for StringParser<F>where
F: Sync,
impl<F> Unpin for StringParser<F>where
F: Unpin,
impl<F> UnwindSafe for StringParser<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<P> ParserExt for Pwhere
P: Parser,
impl<P> ParserExt for Pwhere
P: Parser,
Source§fn otherwise<V: Parser>(self, other: V) -> ChoiceParser<Self, V>where
Self: Sized,
fn otherwise<V: Parser>(self, other: V) -> ChoiceParser<Self, V>where
Self: Sized,
Parse this parser, or another other parser.
Source§fn or<V: Parser<Output = Self::Output>>(
self,
other: V,
) -> MapOutputParser<ChoiceParser<Self, V>, Self::Output>where
Self: Sized,
fn or<V: Parser<Output = Self::Output>>(
self,
other: V,
) -> MapOutputParser<ChoiceParser<Self, V>, Self::Output>where
Self: Sized,
Parse this parser, or another other parser with the same type
Source§fn then<V: Parser>(self, other: V) -> SequenceParser<Self, V>where
Self: Sized,
fn then<V: Parser>(self, other: V) -> SequenceParser<Self, V>where
Self: Sized,
Parse this parser, then the other parser.
Source§fn then_lazy<V, F>(self, other: F) -> ThenLazy<Self, F>
fn then_lazy<V, F>(self, other: F) -> ThenLazy<Self, F>
Parse this parser, then the other parser that is created base on the output of this parser.
Source§fn ignore_output_then<V: CreateParserState>(
self,
other: V,
) -> MapOutputParser<SequenceParser<Self, V>, <V as Parser>::Output>where
Self: Sized,
fn ignore_output_then<V: CreateParserState>(
self,
other: V,
) -> MapOutputParser<SequenceParser<Self, V>, <V as Parser>::Output>where
Self: Sized,
Parse this parser, then the other parser while ignoring the current parser’s output.
Source§fn then_ignore_output<V: CreateParserState>(
self,
other: V,
) -> MapOutputParser<SequenceParser<Self, V>, <Self as Parser>::Output>where
Self: Sized,
fn then_ignore_output<V: CreateParserState>(
self,
other: V,
) -> MapOutputParser<SequenceParser<Self, V>, <Self as Parser>::Output>where
Self: Sized,
Parse this parser, then the other parser while ignoring the output of the other parser.
Source§fn then_literal(
self,
literal: impl Into<Cow<'static, str>>,
) -> MapOutputParser<SequenceParser<Self, LiteralParser>, <Self as Parser>::Output>where
Self: Sized,
fn then_literal(
self,
literal: impl Into<Cow<'static, str>>,
) -> MapOutputParser<SequenceParser<Self, LiteralParser>, <Self as Parser>::Output>where
Self: Sized,
Parse this parser, then a literal. This is equivalent to
.then_ignore_output(LiteralParser::new(literal)).Source§fn repeat(self, length_range: RangeInclusive<usize>) -> RepeatParser<Self>where
Self: Sized,
fn repeat(self, length_range: RangeInclusive<usize>) -> RepeatParser<Self>where
Self: Sized,
Repeat this parser a number of times.
Source§fn map_output<F, O>(self, f: F) -> MapOutputParser<Self, O, F>
fn map_output<F, O>(self, f: F) -> MapOutputParser<Self, O, F>
Map the output of this parser.
Source§fn boxed(self) -> ArcParser<Self::Output>where
Self: CreateParserState + Sized + Send + Sync + 'static,
Self::Output: Send + Sync + 'static,
Self::PartialState: Send + Sync + 'static,
fn boxed(self) -> ArcParser<Self::Output>where
Self: CreateParserState + Sized + Send + Sync + 'static,
Self::Output: Send + Sync + 'static,
Self::PartialState: Send + Sync + 'static,
Get a boxed version of this parser.
Source§fn with_initial_state<F: Fn() -> Self::PartialState + Clone>(
self,
initial_state: F,
) -> WithInitialState<Self, F>where
Self: Sized,
fn with_initial_state<F: Fn() -> Self::PartialState + Clone>(
self,
initial_state: F,
) -> WithInitialState<Self, F>where
Self: Sized,
Create a new parser with a different initial state