DetectUnrecognized

Enum DetectUnrecognized 

Source
pub enum DetectUnrecognized<A, E> {
    Unrecognized(A),
    Error(E),
}
Expand description

An error type that assists state errors with propagating unrecognized arguments.

When a State doesn’t recognize an argument, it returns the argument it got as a function argument, so that it can be retried elsewhere. This enum provides a container for this function argument. This allows the caller of the state method to opt-in or opt-out of actually receiving this unused argument, depending on if it wants to retry it or not.

This type is mostly used by the debate derives.

Variants§

§

Unrecognized(A)

This argument wasn’t recognized and can be retried

§

Error(E)

A different error occurred

Trait Implementations§

Source§

impl<'arg, E> Error<'arg> for DetectUnrecognized<(), E>
where E: Error<'arg>,

Source§

fn needs_arg() -> Self

The parameter requires an argument, and none was provided.
Source§

fn got_arg(arg: &'arg Arg) -> Self

The parameter is a --switch; it must NOT have a value, and got one.
Source§

fn got_additional_instance() -> Self

The argument appeared more times than expected (usually more than once) on the command line
Source§

fn invalid_utf8(arg: &'arg Arg) -> Self

The argument wasn’t valid UTF-8 and should be.
Source§

fn parse_error(arg: &'arg str, msg: impl Display) -> Self

The argument was valid UTF-8, but it failed to parse into an instance of the type.
Source§

fn byte_parse_error(arg: &'arg Arg, msg: impl Display) -> Self

The argument failed to parse into an instance of the type.
Source§

fn should_be(argument: &'arg Arg, expected: &'static [&'static str]) -> Self

The argument should be one of the given values (or, possibly, a case insensitive variation)
Source§

fn custom(msg: impl Display) -> Self

Something else went wrong
Source§

impl<'arg, A, E> Error<'arg, A> for DetectUnrecognized<A, E>
where E: Error<'arg, A>,

Source§

type ParameterError = <E as Error<'arg, A>>::ParameterError

Error type for parameter errors (see parameter).
Source§

type FlagList = <E as Error<'arg, A>>::FlagList

List of flags for conflicts_with_flags.
Source§

fn parameter(field: &'static str, error: Self::ParameterError) -> Self

A parameter type returned an error. This means that the argument was recognized and matched to a specific field, but something went wrong during parsing, such as a letter appearing in a numeric parameter.
Source§

fn unrecognized(argument: A) -> Self

An argument was unrecognized. In this case, the Argument can be returned unused inside of Self, so that it can be retried by a different parser. For instance, a subcommand parser could indicate that an argument is unrecognized, and that argument can later be handled as a global argument.
Source§

fn flattened(field: &'static str, error: Self) -> Self

There was a state error from another State inside of this one.
Source§

fn unknown_subcommand(expected: &'static [&'static str]) -> Self

The positional argument was interpreted as a subcommand, but wasn’t recognized as a known subcommand. The list of known subcommands is given.
Source§

fn wrong_subcommand_for_argument( subcommand: &'static str, allowed: &'static [&'static str], ) -> Self

The option was recognized, but it isn’t a valid for this particular subcommand. The current subcommand, along with the list of subcommands that accept this option, are given
Source§

fn conflicts_with_flags(flags: Self::FlagList) -> Self

The argument conflicts with the given flags that were already parsed.
Source§

fn help_requested(req: HelpRequest) -> Self

This was a request for a usage message. This error doesn’t need to interrupt argument parsing, since it can be useful to have a complete state object to print more contextually useful usage messages.

Auto Trait Implementations§

§

impl<A, E> Freeze for DetectUnrecognized<A, E>
where A: Freeze, E: Freeze,

§

impl<A, E> RefUnwindSafe for DetectUnrecognized<A, E>

§

impl<A, E> Send for DetectUnrecognized<A, E>
where A: Send, E: Send,

§

impl<A, E> Sync for DetectUnrecognized<A, E>
where A: Sync, E: Sync,

§

impl<A, E> Unpin for DetectUnrecognized<A, E>
where A: Unpin, E: Unpin,

§

impl<A, E> UnwindSafe for DetectUnrecognized<A, E>
where A: UnwindSafe, E: 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, 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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.