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>,
impl<'arg, E> Error<'arg> for DetectUnrecognized<(), E>where
E: Error<'arg>,
Source§fn got_arg(arg: &'arg Arg) -> Self
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
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
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
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
fn byte_parse_error(arg: &'arg Arg, msg: impl Display) -> Self
The argument failed to parse into an instance of the type.
Source§impl<'arg, A, E> Error<'arg, A> for DetectUnrecognized<A, E>where
E: Error<'arg, A>,
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
type ParameterError = <E as Error<'arg, A>>::ParameterError
Error type for parameter errors (see
parameter).Source§fn parameter(field: &'static str, error: Self::ParameterError) -> Self
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
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
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
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
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
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
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>
impl<A, E> RefUnwindSafe for DetectUnrecognized<A, E>where
A: RefUnwindSafe,
E: RefUnwindSafe,
impl<A, E> Send for DetectUnrecognized<A, E>
impl<A, E> Sync for DetectUnrecognized<A, E>
impl<A, E> Unpin for DetectUnrecognized<A, E>
impl<A, E> UnwindSafe for DetectUnrecognized<A, E>where
A: UnwindSafe,
E: 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