pub struct ValidationError { /* private fields */ }Expand description
A command-wide validation or finalization failure.
Return this from a #[usage(validate_with = ...)] hook or from the
TryFrom implementation named by #[usage(try_into = ...)]. The derive
turns it into the same Error::InvalidValue diagnostic used by field
conversion, so callers keep one parse error type.
Implementations§
Source§impl ValidationError
impl ValidationError
Sourcepub fn field(name: &'static str) -> ValidationError
pub fn field(name: &'static str) -> ValidationError
Start an error attributed to a flag, positional, or command name.
Sourcepub fn value(self, value: impl Into<String>) -> ValidationError
pub fn value(self, value: impl Into<String>) -> ValidationError
Record the value that failed the command-wide invariant.
Sourcepub fn reason(self, reason: impl Into<String>) -> ValidationError
pub fn reason(self, reason: impl Into<String>) -> ValidationError
Explain the invariant that the value did not satisfy.
Sourcepub fn into_parse_error<'v>(self) -> Error<'static, 'v>
pub fn into_parse_error<'v>(self) -> Error<'static, 'v>
Convert this application-level failure into the parser’s diagnostic.
Trait Implementations§
Source§impl Clone for ValidationError
impl Clone for ValidationError
Source§fn clone(&self) -> ValidationError
fn clone(&self) -> ValidationError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValidationError
impl Debug for ValidationError
impl Eq for ValidationError
Source§impl PartialEq for ValidationError
impl PartialEq for ValidationError
impl StructuralPartialEq for ValidationError
Auto Trait Implementations§
impl Freeze for ValidationError
impl RefUnwindSafe for ValidationError
impl Send for ValidationError
impl Sync for ValidationError
impl Unpin for ValidationError
impl UnsafeUnpin for ValidationError
impl UnwindSafe for ValidationError
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