Skip to main content

ArgumentErrorKind

Enum ArgumentErrorKind 

Source
#[non_exhaustive]
pub enum ArgumentErrorKind {
Show 15 variants Missing, Blank, Empty, Length { actual: usize, constraint: LengthConstraint, metric: LengthMetric, }, Comparison { actual: ArgumentValue, constraint: ComparisonConstraint, }, Range { actual: ArgumentValue, constraint: RangeConstraint, }, InvalidLengthConstraint { constraint: LengthConstraint, metric: LengthMetric, }, InvalidRangeConstraint { constraint: RangeConstraint, }, NotANumber, NotFinite { actual: ArgumentValue, }, Index { index: usize, size: usize, role: IndexRole, }, IndexRange { start: usize, end: usize, size: usize, }, Bounds { offset: usize, length: usize, total_length: usize, }, Pattern { pattern: String, expectation: PatternExpectation, }, Custom { code: String, message: String, },
}
Expand description

Identifies the validation rule that an argument failed.

Each variant stores only structured context needed to inspect and format the failure. Validated string contents are never captured implicitly.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Missing

The required argument was absent.

§

Blank

The string argument contained no non-whitespace characters.

§

Empty

The collection argument was empty.

§

Length

The argument length did not satisfy a length constraint.

Fields

§actual: usize

The observed length in the unit identified by metric.

§constraint: LengthConstraint

The required length relationship.

§metric: LengthMetric

The unit used to measure the observed and required lengths.

§

Comparison

A scalar argument did not satisfy a comparison constraint.

Fields

§actual: ArgumentValue

The observed numeric or duration value.

§constraint: ComparisonConstraint

The required comparison relationship.

§

Range

The numeric argument was outside a required range.

Fields

§actual: ArgumentValue

The observed numeric value.

§constraint: RangeConstraint

The required range.

§

InvalidLengthConstraint

The supplied length constraint was internally invalid.

Fields

§constraint: LengthConstraint

The invalid length constraint.

§metric: LengthMetric

The unit to which the invalid constraint would have applied.

§

InvalidRangeConstraint

The supplied numeric range was internally invalid.

Fields

§constraint: RangeConstraint

The invalid numeric range.

§

NotANumber

The argument or numeric constraint contained a floating-point NaN value.

§

NotFinite

The floating-point argument was positive or negative infinity.

Fields

§actual: ArgumentValue

The rejected infinite floating-point value.

§

Index

An element or position index was outside its valid domain.

Fields

§index: usize

The rejected index.

§size: usize

The collection size used for validation.

§role: IndexRole

Whether the index identifies an element or a position.

§

IndexRange

A position range was invalid for a collection size.

Fields

§start: usize

The inclusive start position.

§end: usize

The exclusive end position.

§size: usize

The collection size used for validation.

§

Bounds

An offset and length did not fit within a total length.

Fields

§offset: usize

The rejected starting offset.

§length: usize

The rejected span length.

§total_length: usize

The available total length.

§

Pattern

A string did not satisfy a pattern expectation.

Fields

§pattern: String

The pattern text used for validation.

§expectation: PatternExpectation

Whether a match or non-match was required.

§

Custom

A caller-defined validation rule failed.

Fields

§code: String

A machine-readable caller-defined code.

§message: String

A human-readable caller-defined explanation.

Trait Implementations§

Source§

impl Clone for ArgumentErrorKind

Source§

fn clone(&self) -> ArgumentErrorKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ArgumentErrorKind

Source§

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

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

impl Eq for ArgumentErrorKind

Source§

impl PartialEq for ArgumentErrorKind

Source§

fn eq(&self, other: &ArgumentErrorKind) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ArgumentErrorKind

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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