pub struct Filter<Parser, F> { /* private fields */ }
Expand description
Implementation of crate::Utils::filter
Trait Implementations§
Source§impl<Stream, Context, Parser, F> Parse<Stream, Context> for Filter<Parser, F>
impl<Stream, Context, Parser, F> Parse<Stream, Context> for Filter<Parser, F>
Source§type Token = <Parser as Parse<Stream, Context>>::Token
type Token = <Parser as Parse<Stream, Context>>::Token
Token is what the parser produced.
For example, a parser that read an u32 would have as Token u32.
Source§fn parse(&mut self, stream: Stream) -> Parsed<Self::Token, Stream, Context>
fn parse(&mut self, stream: Stream) -> Parsed<Self::Token, Stream, Context>
The main method of binator, any parser will be called by this method.
parse()
will take a stream as parameter and eat data from it to produce
a Token. The result is what the parser Parsed
is an enum of possible
outcome.Auto Trait Implementations§
impl<Parser, F> Freeze for Filter<Parser, F>
impl<Parser, F> RefUnwindSafe for Filter<Parser, F>where
Parser: RefUnwindSafe,
F: RefUnwindSafe,
impl<Parser, F> Send for Filter<Parser, F>
impl<Parser, F> Sync for Filter<Parser, F>
impl<Parser, F> Unpin for Filter<Parser, F>
impl<Parser, F> UnwindSafe for Filter<Parser, F>where
Parser: UnwindSafe,
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<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Set the foreground color generically Read more
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Set the background color generically. Read more
Source§fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>
fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>
Change the foreground color to black
Source§fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>
fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>
Change the background color to black
Source§fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>
fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>
Change the foreground color to red
Source§fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>
fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>
Change the background color to red
Source§fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>
fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>
Change the foreground color to green
Source§fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>
fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>
Change the background color to green
Source§fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>
Change the foreground color to yellow
Source§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
Change the background color to yellow
Source§fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>
Change the foreground color to blue
Source§fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>
Change the background color to blue
Source§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
Change the foreground color to magenta
Source§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
Change the background color to magenta
Source§fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
Change the foreground color to purple
Source§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
Change the background color to purple
Source§fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>
Change the foreground color to cyan
Source§fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>
Change the background color to cyan
Source§fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>
fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>
Change the foreground color to white
Source§fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>
fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>
Change the background color to white
Source§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
Change the foreground color to the terminal default
Source§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
Change the background color to the terminal default
Source§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
Change the foreground color to bright black
Source§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
Change the background color to bright black
Source§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
Change the foreground color to bright red
Source§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
Change the background color to bright red
Source§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
Change the foreground color to bright green
Source§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
Change the background color to bright green
Source§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
Change the foreground color to bright yellow
Source§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
Change the background color to bright yellow
Source§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
Change the foreground color to bright blue
Source§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
Change the background color to bright blue
Source§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright magenta
Source§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
Change the background color to bright magenta
Source§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright purple
Source§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
Change the background color to bright purple
Source§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
Change the foreground color to bright cyan
Source§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
Change the background color to bright cyan
Source§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
Change the foreground color to bright white
Source§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
Change the background color to bright white
Source§fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>
fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>
Make the text bold
Source§fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>
fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>
Make the text dim
Source§fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>
fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>
Make the text italicized
Source§fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>
fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>
Make the text italicized
Source§fn blink<'a>(&'a self) -> BlinkDisplay<'a, Self>
fn blink<'a>(&'a self) -> BlinkDisplay<'a, Self>
Make the text blink
Source§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
Make the text blink (but fast!)
Source§fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>
fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>
Swap the foreground and background colors
Hide the text
Source§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
Cross out the text
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
Set the foreground color at runtime. Only use if you do not know which color will be used at
compile-time. If the color is constant, use either
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
Set the background color at runtime. Only use if you do not know what color to use at
compile-time. If the color is constant, use either
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the foreground color to a specific RGB value.
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the background color to a specific RGB value.
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Sets the foreground color to an RGB value.
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Sets the background color to an RGB value.
Source§impl<T, Stream, Context> Utils<Stream, Context> for T
impl<T, Stream, Context> Utils<Stream, Context> for T
Source§fn and_then<OtherParser, F>(self, f: F) -> AndThen<Self, F>
fn and_then<OtherParser, F>(self, f: F) -> AndThen<Self, F>
and_then will call the underline parser, if successful it will call the
function in parameter and give it the produced Token. The function must
return a new parser that will be called to producted the Token returned
by and_then parser.
Source§fn and<OtherParser, OtherToken>(
self,
other: OtherParser,
) -> And<Self, OtherParser>where
OtherParser: Parse<Stream, Context, Token = OtherToken>,
fn and<OtherParser, OtherToken>(
self,
other: OtherParser,
) -> And<Self, OtherParser>where
OtherParser: Parse<Stream, Context, Token = OtherToken>,
and combinator will call the underline parser, and if successful the
parser given in parameter. If the second parser is also successful, and
combinator will return a tuple that contain the two Token producted.
Source§fn and_drop<OtherParser, OtherToken>(
self,
other: OtherParser,
) -> AndDrop<Self, OtherParser>where
OtherParser: Parse<Stream, Context, Token = OtherToken>,
fn and_drop<OtherParser, OtherToken>(
self,
other: OtherParser,
) -> AndDrop<Self, OtherParser>where
OtherParser: Parse<Stream, Context, Token = OtherToken>,
Same than and combinator but it will drop the second Token instead,
returning only the first Token from the inner parser.
Source§fn drop_and<OtherParser, OtherToken>(
self,
other: OtherParser,
) -> DropAnd<Self, OtherParser>where
OtherParser: Parse<Stream, Context, Token = OtherToken>,
fn drop_and<OtherParser, OtherToken>(
self,
other: OtherParser,
) -> DropAnd<Self, OtherParser>where
OtherParser: Parse<Stream, Context, Token = OtherToken>,
Same than and combinator but it will drop the underline Token instead,
returning only the second Token from the parser in parameter.
Source§fn drop(self) -> Drop<Self>
fn drop(self) -> Drop<Self>
Call the underline parser but drop the Token if sucessful. This can be
considered as a shortcut of the toilet closure:
.map(|_| ())
.Source§fn fill<const N: usize>(self) -> Fill<Self, N>where
Context: Contexting<UtilsAtom<Stream>>,
fn fill<const N: usize>(self) -> Fill<Self, N>where
Context: Contexting<UtilsAtom<Stream>>,
Will call the underline parser N times to fill an array of size N and
return [Token; N] if successfull
Source§fn try_fold_iter<IntoIter, Init, Acc, Ret, F>(
self,
iter: IntoIter,
init: Init,
f: F,
) -> TryFoldIter<Self, IntoIter, Init, F>where
Context: Contexting<UtilsAtom<Stream>>,
IntoIter: IntoIterator + Clone,
Init: Fn() -> Ret,
F: Fn(Acc, Self::Token, IntoIter::Item) -> Ret,
Ret: Try<Output = Acc>,
Parsed<Acc, Stream, Context>: FromResidual<Ret::Residual>,
fn try_fold_iter<IntoIter, Init, Acc, Ret, F>(
self,
iter: IntoIter,
init: Init,
f: F,
) -> TryFoldIter<Self, IntoIter, Init, F>where
Context: Contexting<UtilsAtom<Stream>>,
IntoIter: IntoIterator + Clone,
Init: Fn() -> Ret,
F: Fn(Acc, Self::Token, IntoIter::Item) -> Ret,
Ret: Try<Output = Acc>,
Parsed<Acc, Stream, Context>: FromResidual<Ret::Residual>,
This combinator take a Iterator, it will call the inner parser
as many time the iterator lenght. The Item produced and the Token
produced will be given to the function F along with the accumulator
produced by Init function. The Init and F function can use return any
type that implement Try. The Token produced is the last accumulator value.
Source§fn fold_until<TokenUntil, Acc, Until, Init, F>(
self,
until: Until,
init: Init,
f: F,
) -> FoldUntil<Self, Until, Init, F>
fn fold_until<TokenUntil, Acc, Until, Init, F>( self, until: Until, init: Init, f: F, ) -> FoldUntil<Self, Until, Init, F>
This Combinator will call the inner parser as long as the until
parser is not successful, each Token produced will be feed to F
function along with the accumulator. Read more
Source§fn try_fold_until<TokenUntil, Acc, Parser, Until, Init, Ret, F>(
self,
until: Until,
init: Init,
f: F,
) -> TryFoldUntil<Self, Until, Init, F>
fn try_fold_until<TokenUntil, Acc, Parser, Until, Init, Ret, F>( self, until: Until, init: Init, f: F, ) -> TryFoldUntil<Self, Until, Init, F>
The same then fold_until but can be used with type that implement Try
Source§fn fold_bounds<Bounds, Acc, Init, F>(
self,
bounds: Bounds,
init: Init,
f: F,
) -> FoldBounds<Self, Bounds, Init, F>where
Context: Contexting<UtilsAtom<Stream>>,
Init: FnMut() -> Acc,
F: FnMut(Acc, Self::Token) -> Acc,
Bounds: FoldBoundsParse,
Acc: Debug,
fn fold_bounds<Bounds, Acc, Init, F>(
self,
bounds: Bounds,
init: Init,
f: F,
) -> FoldBounds<Self, Bounds, Init, F>where
Context: Contexting<UtilsAtom<Stream>>,
Init: FnMut() -> Acc,
F: FnMut(Acc, Self::Token) -> Acc,
Bounds: FoldBoundsParse,
Acc: Debug,
Main fold combinator, the bahavior depend on the Bounds argument.
This combinator is implemented for Range and usize. The number of
iteration depend of the type and the value used for the Bounds argument. Read more
Source§fn try_fold_bounds<Bounds, Acc, Init, Ret, F>(
self,
bounds: Bounds,
init: Init,
f: F,
) -> TryFoldBounds<Self, Bounds, Init, F>where
Context: Contexting<UtilsAtom<Stream>>,
Init: Fn() -> Ret,
F: Fn(Acc, Self::Token) -> Ret,
Ret: Try<Output = Acc>,
Parsed<Acc, Stream, Context>: FromResidual<Ret::Residual>,
Bounds: TryFoldBoundsParse,
Acc: Debug,
fn try_fold_bounds<Bounds, Acc, Init, Ret, F>(
self,
bounds: Bounds,
init: Init,
f: F,
) -> TryFoldBounds<Self, Bounds, Init, F>where
Context: Contexting<UtilsAtom<Stream>>,
Init: Fn() -> Ret,
F: Fn(Acc, Self::Token) -> Ret,
Ret: Try<Output = Acc>,
Parsed<Acc, Stream, Context>: FromResidual<Ret::Residual>,
Bounds: TryFoldBoundsParse,
Acc: Debug,
Same than fold_bounds but F and Acc can return type that implement Try
Source§fn add_atom<F, Atom>(self, f: F) -> AddAtom<Self, F>where
F: Fn() -> Atom,
Context: Contexting<Atom>,
fn add_atom<F, Atom>(self, f: F) -> AddAtom<Self, F>where
F: Fn() -> Atom,
Context: Contexting<Atom>,
if the underline parser is not successful it will add call
F and add the Atom provided to the Context
Source§fn map<F, OtherToken>(self, f: F) -> Map<Self, F>
fn map<F, OtherToken>(self, f: F) -> Map<Self, F>
If the underline parser is successful it will call F
with the Token produced and change return a new Success with
the Token returned by F.
Source§fn filter_map<F, OtherToken>(self, f: F) -> FilterMap<Self, F>
fn filter_map<F, OtherToken>(self, f: F) -> FilterMap<Self, F>
Merge of map and filter combinator, only return Success if
F return Some.
Source§fn to<OtherToken>(self, t: OtherToken) -> To<Self, OtherToken>where
OtherToken: Clone,
fn to<OtherToken>(self, t: OtherToken) -> To<Self, OtherToken>where
OtherToken: Clone,
If underline parse is successful it will drop the Token and replace it
with the token in argument. This is mostly a inconditional .map()
usefull to avoid the closure. (Can be used in Slice parser where map is
not)
Source§fn not(self) -> Not<Self>
fn not(self) -> Not<Self>
Evil Combinator, it will reverse Success in Failure and
Failure in Success but will not touch Error. This Combinator
should probably never be used.
Source§fn opt(self) -> Optional<Self>where
Stream: Clone,
fn opt(self) -> Optional<Self>where
Stream: Clone,
Make a parser optional allowing failure. Return Some(Token)
in case of Success of underline parser and None in case of Failure.
This parser can’t fail.
Source§fn enumerate(self) -> Enumerate<Self>
fn enumerate(self) -> Enumerate<Self>
Very much like Iterator .enumerate(). It will add a counter to every
Token produced. Return a tuple
(counter, Token)
.Source§fn limit(self, n: usize) -> Limit<Self>where
Context: Contexting<UtilsAtom<Stream>>,
fn limit(self, n: usize) -> Limit<Self>where
Context: Contexting<UtilsAtom<Stream>>,
Very much like Iterator .take(), it will only allow n call to inner parser
before returning Failure. This parser use a state be aware that it must be
recreate to be reset.
Source§fn or<OtherParser>(self, b: OtherParser) -> Or<Self, OtherParser>
fn or<OtherParser>(self, b: OtherParser) -> Or<Self, OtherParser>
Allow branching, or will call the inner parser and if not sucessful
it will call the second parser. or can be chained many time allowing
multiple branch.
Source§fn peek(self) -> Peek<Self>where
Stream: Clone,
fn peek(self) -> Peek<Self>where
Stream: Clone,
peek allow to not consume the Stream but return the Token it would have
produced. It should be used very often since you would parse more than
once the same input.
Source§fn span(self) -> Span<Self>where
Context: Contexting<UtilsAtom<Stream>>,
fn span(self) -> Span<Self>where
Context: Contexting<UtilsAtom<Stream>>,
span allow to save the Stream consumed by the underline parser in a form
of a Span. This is very usefull for error or to avoid fully tokenize an
input. Be aware that Span can contains lifetime since it’s linked to
Stream implementation. For example, an Stream of slice u8 will contains
a lifetime.