pub enum ValidationResult {
Passed,
Failed {
message: String,
violations: Vec<String>,
},
Warning {
message: String,
underlying: Box<Self>,
},
}Expand description
The outcome of validating a value against a parameter or constraint.
See SRD-0004 §ValidationResult. The Warning variant is flattened by
construction (never Warning { underlying: Warning { .. } }); callers
should use Self::warn rather than constructing the variant directly.
Variants§
Passed
The value passed all checks.
Failed
The value failed at least one check.
Fields
Warning
The value is acceptable but worth flagging. Exactly one level of warning may wrap an inner result.
Implementations§
Source§impl ValidationResult
impl ValidationResult
Sourcepub const fn passed() -> Self
pub const fn passed() -> Self
Construct a passing result. Provided for symmetry with the other constructors.
Sourcepub fn failed(message: impl Into<String>, violations: Vec<String>) -> Self
pub fn failed(message: impl Into<String>, violations: Vec<String>) -> Self
Construct a failing result.
Sourcepub fn warn(message: impl Into<String>, inner: Self) -> Self
pub fn warn(message: impl Into<String>, inner: Self) -> Self
Wrap an inner result with a warning. Flattens nested warnings.
If inner is itself a Warning, its own inner result is lifted
so the returned value has exactly one warning layer. Messages
from discarded inner warnings are lost; use the outer message
to carry anything the caller needs to preserve.
Sourcepub fn is_passed(&self) -> bool
pub fn is_passed(&self) -> bool
true when the effective outcome is a pass (either Passed or a
warning whose underlying result is Passed).
Sourcepub fn violations(&self) -> &[String]
pub fn violations(&self) -> &[String]
Borrow the violation list, if any. Descends one level of warning.
Trait Implementations§
Source§impl Clone for ValidationResult
impl Clone for ValidationResult
Source§fn clone(&self) -> ValidationResult
fn clone(&self) -> ValidationResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ValidationResult
impl Debug for ValidationResult
Source§impl<'de> Deserialize<'de> for ValidationResult
impl<'de> Deserialize<'de> for ValidationResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ValidationResult
impl PartialEq for ValidationResult
Source§impl Serialize for ValidationResult
impl Serialize for ValidationResult
impl Eq for ValidationResult
impl StructuralPartialEq for ValidationResult
Auto Trait Implementations§
impl Freeze for ValidationResult
impl RefUnwindSafe for ValidationResult
impl Send for ValidationResult
impl Sync for ValidationResult
impl Unpin for ValidationResult
impl UnsafeUnpin for ValidationResult
impl UnwindSafe for ValidationResult
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.