#[non_exhaustive]pub enum Error {
Show 19 variants
DisplayHelp {
help: String,
},
DisplayVersion {
version: String,
},
DisplaySchema {
schema: String,
},
DisplayCompletion {
completion: String,
},
UnknownFlag {
token: Vec<u8>,
},
MissingValue {
name: &'static str,
possible_values: &'static [&'static str],
},
UnexpectedValue {
name: &'static str,
},
UnexpectedArgument {
token: Vec<u8>,
usage: Option<String>,
},
UnknownCommand {
token: Vec<u8>,
},
MissingSubcommand {
name: &'static str,
},
MissingRequired {
name: &'static str,
},
MissingRequiredArguments {
argument: String,
usage: String,
},
DuplicateArgument {
name: &'static str,
usage: Option<String>,
},
MissingRequirement {
name: &'static str,
required_by: &'static str,
},
ConflictingArguments {
name: &'static str,
other: &'static str,
},
InvalidOneOf {
arguments: String,
},
InvalidAnyOf {
arguments: String,
},
InvalidUtf8 {
name: &'static str,
value: Vec<u8>,
},
InvalidValue {
name: &'static str,
value: String,
reason: String,
},
}Expand description
A built-in parser action or command-line parsing failure.
Help, version, schema, and completion requests are represented alongside ordinary parsing
errors so callers of the try_parse* methods can choose how to handle them.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
DisplayHelp
Generated help requested through the built-in help switch.
DisplayVersion
Version information requested through the built-in version action.
DisplaySchema
Machine-readable command schema requested through built-in discovery.
DisplayCompletion
Dynamic shell-completion output requested through Argx’s private completion protocol.
UnknownFlag
A flag-like token did not match any declared flag.
MissingValue
A flag that consumes a value did not receive one.
Fields
UnexpectedValue
A value was attached to a switch that does not accept one.
UnexpectedArgument
A word could not be assigned to any positional argument.
Fields
UnknownCommand
A word did not match any child command when command selection was required.
MissingSubcommand
A required subcommand field was not selected.
MissingRequired
A required field was not supplied during generated binding.
MissingRequiredArguments
One or more required arguments were missing from a parsed command invocation.
Fields
DuplicateArgument
A scalar argument was supplied more than once.
Fields
MissingRequirement
An argument required by another supplied argument was not available.
Fields
ConflictingArguments
Two arguments declared to conflict were supplied together.
Fields
InvalidOneOf
A one_of set had zero or multiple explicitly supplied members.
InvalidAnyOf
An any_of set had no explicitly supplied member.
InvalidUtf8
A text value was not valid UTF-8.
Fields
InvalidValue
A UTF-8 value could not be converted to the field’s Rust type.
Implementations§
Source§impl Error
impl Error
Sourcepub const fn exit_code(&self) -> i32
pub const fn exit_code(&self) -> i32
Returns the process status used by Self::exit.
§Examples
let help = argx::Error::DisplayHelp { help: String::new() };
let failure = argx::Error::UnknownFlag { token: b"--bad".to_vec() };
assert_eq!(help.exit_code(), 0);
assert_eq!(failure.exit_code(), 2);Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 64 bytes
Size for each variant:
DisplayHelp: 32 bytesDisplayVersion: 32 bytesDisplaySchema: 32 bytesDisplayCompletion: 32 bytesUnknownFlag: 32 bytesMissingValue: 40 bytesUnexpectedValue: 24 bytesUnexpectedArgument: 56 bytesUnknownCommand: 32 bytesMissingSubcommand: 24 bytesMissingRequired: 24 bytesMissingRequiredArguments: 56 bytesDuplicateArgument: 48 bytesMissingRequirement: 40 bytesConflictingArguments: 40 bytesInvalidOneOf: 32 bytesInvalidAnyOf: 32 bytesInvalidUtf8: 48 bytesInvalidValue: 64 bytes