Enum binator::Parsed

source ·
pub enum Parsed<Token, Stream, Context> {
    Success {
        token: Token,
        stream: Stream,
    },
    Failure(Context),
    Error(Context),
}
Expand description

Parsed represent the result of a parse().

Variants§

§

Success

Fields

§token: Token

token produced by the parser.

§stream: Stream

the stream used by the parser, should have less item than before.

When parser successfully parse the stream

§

Failure(Context)

When parser fail to parse the stream. This is not fatal and is a normal behavior for a parser.

§

Error(Context)

When parser encouter an error, this should be fatal. Could be a programming error or something wrong will the stream.

Implementations§

source§

impl<Token, Stream, Context> Parsed<Token, Stream, Context>

source

pub const fn new_success(token: Token, stream: Stream) -> Self

Shortcut for Parsed::Success { token, stream }

source

pub const fn new_failure(content: Context) -> Self

Shortcut for Parsed::Failure(context_handle)

source

pub const fn new_error(content: Context) -> Self

Shortcut for Parsed::Error(context_handle)

source

pub const fn as_ref(&self) -> Parsed<&Token, &Stream, &Context>

Borrow Parsed to make temporary Parsed of reference

source

pub fn map_success<MappedToken, Map>( self, map: Map ) -> Parsed<MappedToken, Stream, Context>
where Map: FnOnce(Success<Token, Stream>) -> Success<MappedToken, Stream>,

Allow to quickly access success to map it.

source

pub fn map_token<MappedToken, Map>( self, map: Map ) -> Parsed<MappedToken, Stream, Context>
where Map: FnOnce(Token) -> MappedToken,

Allow to quickly access token to map it.

source

pub fn map_stream<Map>(self, map: Map) -> Parsed<Token, Stream, Context>
where Map: FnOnce(Stream) -> Stream,

Allow to quickly access stream to map it.

source

pub fn map_context<MappedAtom, Map>( self, map: Map ) -> Parsed<Token, Stream, MappedAtom>
where Map: FnOnce(Context) -> MappedAtom,

Allow to quickly access context to map it.

source

pub fn add_context<C, Map>(self, map: Map) -> Parsed<Token, Stream, Context>
where Map: FnOnce() -> C, Context: Contexting<C>,

Shortcut to add a Atom to the Context

source

pub fn unwrap(self) -> Success<Token, Stream>
where Context: Debug,

Return Success if Parsed is Success otherwise panic. Use only for testing purpose.

source

pub fn unwrap_context(self) -> Context
where Token: Debug, Stream: Debug,

Return Context if Parsed is Failure or Error otherwise panic. Use only for testing purpose.

source

pub const fn is_success(&self) -> bool

Return true if Parsed is Success.

Trait Implementations§

source§

impl<Token: Clone, Stream: Clone, Context: Clone> Clone for Parsed<Token, Stream, Context>

source§

fn clone(&self) -> Parsed<Token, Stream, Context>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Token: Debug, Stream: Debug, Context: Debug> Debug for Parsed<Token, Stream, Context>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, Token, Stream, Context> Deserialize<'de> for Parsed<Token, Stream, Context>
where Token: Deserialize<'de>, Stream: Deserialize<'de>, Context: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<Token, Stream, Context> Display for Parsed<Token, Stream, Context>
where Token: Debug, Stream: Streaming, Context: ProvideElement,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Token, Stream, Context> From<Success<Token, Stream>> for Parsed<Token, Stream, Context>

source§

fn from(_: Success<Token, Stream>) -> Self

Converts to this type from the input type.
source§

impl<Token, Stream, Context> FromResidual<ParsedAux<Infallible, Context>> for Parsed<Token, Stream, Context>

source§

fn from_residual(residual: ParsedAux<Infallible, Context>) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from a compatible Residual type. Read more
source§

impl<Token, Stream, Context> FromResidual<Result<Infallible, Context>> for Parsed<Token, Stream, Context>

source§

fn from_residual(residual: Result<Infallible, Context>) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from a compatible Residual type. Read more
source§

impl<Token, Stream, Context> FromResidual for Parsed<Token, Stream, Context>

source§

fn from_residual(residual: Parsed<Infallible, Infallible, Context>) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from a compatible Residual type. Read more
source§

impl<Token: Hash, Stream: Hash, Context: Hash> Hash for Parsed<Token, Stream, Context>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<Token: Ord, Stream: Ord, Context: Ord> Ord for Parsed<Token, Stream, Context>

source§

fn cmp(&self, other: &Parsed<Token, Stream, Context>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<Token: PartialEq, Stream: PartialEq, Context: PartialEq> PartialEq for Parsed<Token, Stream, Context>

source§

fn eq(&self, other: &Parsed<Token, Stream, Context>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Token: PartialOrd, Stream: PartialOrd, Context: PartialOrd> PartialOrd for Parsed<Token, Stream, Context>

source§

fn partial_cmp( &self, other: &Parsed<Token, Stream, Context> ) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<Token, Stream, Context> Serialize for Parsed<Token, Stream, Context>
where Token: Serialize, Stream: Serialize, Context: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<Token, Stream, Context> Try for Parsed<Token, Stream, Context>

§

type Output = Success<Token, Stream>

🔬This is a nightly-only experimental API. (try_trait_v2)
The type of the value produced by ? when not short-circuiting.
§

type Residual = Parsed<Infallible, Infallible, Context>

🔬This is a nightly-only experimental API. (try_trait_v2)
The type of the value passed to FromResidual::from_residual as part of ? when short-circuiting. Read more
source§

fn from_output(output: Self::Output) -> Self

🔬This is a nightly-only experimental API. (try_trait_v2)
Constructs the type from its Output type. Read more
source§

fn branch(self) -> ControlFlow<Self::Residual, Self::Output>

🔬This is a nightly-only experimental API. (try_trait_v2)
Used in ? to decide whether the operator should produce a value (because this returned ControlFlow::Continue) or propagate a value back to the caller (because this returned ControlFlow::Break). Read more
source§

impl<Token: Eq, Stream: Eq, Context: Eq> Eq for Parsed<Token, Stream, Context>

source§

impl<Token, Stream, Context> StructuralPartialEq for Parsed<Token, Stream, Context>

Auto Trait Implementations§

§

impl<Token, Stream, Context> Freeze for Parsed<Token, Stream, Context>
where Context: Freeze, Stream: Freeze, Token: Freeze,

§

impl<Token, Stream, Context> RefUnwindSafe for Parsed<Token, Stream, Context>
where Context: RefUnwindSafe, Stream: RefUnwindSafe, Token: RefUnwindSafe,

§

impl<Token, Stream, Context> Send for Parsed<Token, Stream, Context>
where Context: Send, Stream: Send, Token: Send,

§

impl<Token, Stream, Context> Sync for Parsed<Token, Stream, Context>
where Context: Sync, Stream: Sync, Token: Sync,

§

impl<Token, Stream, Context> Unpin for Parsed<Token, Stream, Context>
where Context: Unpin, Stream: Unpin, Token: Unpin,

§

impl<Token, Stream, Context> UnwindSafe for Parsed<Token, Stream, Context>
where Context: UnwindSafe, Stream: UnwindSafe, Token: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<D> OwoColorize for D

source§

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,

Set the background color generically. Read more
source§

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>

Change the background color to black
source§

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>

Change the background color to red
source§

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>

Change the background color to green
source§

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>

Change the background color to yellow
source§

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>

Change the background color to blue
source§

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>

Change the background color to magenta
source§

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>

Change the background color to purple
source§

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>

Change the background color to cyan
source§

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>

Change the background color to white
source§

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>

Change the background color to the terminal default
source§

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>

Change the background color to bright black
source§

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>

Change the background color to bright red
source§

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>

Change the background color to bright green
source§

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>

Change the background color to bright yellow
source§

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>

Change the background color to bright blue
source§

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>

Change the background color to bright magenta
source§

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>

Change the background color to bright purple
source§

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>

Change the background color to bright cyan
source§

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>

Change the background color to bright white
source§

fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>

Make the text bold
source§

fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>

Make the text dim
source§

fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>

Make the text italicized
source§

fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>

Make the text italicized
Make the text blink
Make the text blink (but fast!)
source§

fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>

Swap the foreground and background colors
source§

fn hidden<'a>(&'a self) -> HiddenDisplay<'a, Self>

Hide the text
source§

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,

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 more
source§

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 more
source§

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>

Set the background color to a specific RGB value.
source§

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>

Sets the background color to an RGB value.
source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,