pub struct Violation { /* private fields */ }Expand description
Represents Violation found during validation with detailed error message, error code and the constraint for which the validation failed
Equivalence of Violation is not supported due to its tree structure of having children Violations.
Please use macro assert_equivalent_violations!(violation1, violation2) for comparing if two violations are equal.
This macro uses flattened_violations and does not depend on the order of the children Violations.
For non-equivalent violations use macro assert_non_equivalent_violations!(violation1, violation2).
Implementations§
Source§impl Violation
impl Violation
pub fn new<A: AsRef<str>, B: AsRef<str>>( constraint: A, code: ViolationCode, message: B, ion_path: &mut IonPath, ) -> Self
pub fn with_violations<A: AsRef<str>, B: AsRef<str>>( constraint: A, code: ViolationCode, message: B, ion_path: &mut IonPath, violations: Vec<Violation>, ) -> Self
pub fn ion_path(&self) -> &IonPath
pub fn message(&self) -> &String
pub fn code(&self) -> &ViolationCode
Sourcepub fn flattened_violations(&self) -> Vec<&Violation>
pub fn flattened_violations(&self) -> Vec<&Violation>
Provides flattened list of leaf violations which represent the root cause of the top-level violation.
pub fn violations(&self) -> impl Iterator<Item = &Violation>
Trait Implementations§
Source§impl Error for Violation
impl Error for Violation
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for Violation
impl RefUnwindSafe for Violation
impl Send for Violation
impl Sync for Violation
impl Unpin for Violation
impl UnsafeUnpin for Violation
impl UnwindSafe for Violation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more