pub struct Violations { /* private fields */ }Expand description
Accumulator for Validate::validate_all implementations.
Feed each check into check: a failing ConfigError is
recorded and evaluation continues, so one pass collects every violation.
into_result then yields Ok(()) when nothing failed
or the full list otherwise.
use rlevo_core::config::{self, Violations};
let mut v = Violations::new();
v.check(config::positive("Demo", "a", -1.0)); // fails
v.check(config::nonzero("Demo", "b", 3)); // ok
v.check(config::in_range("Demo", "c", 0.0, 1.0, 2.0)); // fails
let errs = v.into_result().unwrap_err();
assert_eq!(errs.len(), 2);
assert_eq!(errs[0].field, "a");
assert_eq!(errs[1].field, "c");Implementations§
Source§impl Violations
impl Violations
Sourcepub fn check(&mut self, check: Result<(), ConfigError>)
pub fn check(&mut self, check: Result<(), ConfigError>)
Records check when it failed; a passing check is a no-op. Either way
evaluation continues, so callers list all their invariants back to back.
Sourcepub fn into_result(self) -> Result<(), Vec<ConfigError>>
pub fn into_result(self) -> Result<(), Vec<ConfigError>>
Consumes the accumulator: Ok(()) if nothing failed, otherwise every
collected violation.
§Errors
Returns the non-empty Vec<ConfigError> of all recorded violations.
Trait Implementations§
Source§impl Debug for Violations
impl Debug for Violations
Source§impl Default for Violations
impl Default for Violations
Source§fn default() -> Violations
fn default() -> Violations
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Violations
impl RefUnwindSafe for Violations
impl Send for Violations
impl Sync for Violations
impl Unpin for Violations
impl UnsafeUnpin for Violations
impl UnwindSafe for Violations
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more