#[non_exhaustive]pub enum PreparedOutcome {
Valid,
Invalid(Vec<ViolationDraft>),
}Expand description
The type-erased result produced before rule identity is attached.
§Examples
use qubit_validator::{PreparedOutcome, ViolationCode, ViolationDraft};
let accepted = PreparedOutcome::valid();
let rejected = PreparedOutcome::invalid(vec![
ViolationDraft::new(ViolationCode::new("text.blank")),
])?;
assert!(matches!(accepted, PreparedOutcome::Valid));
assert!(matches!(rejected, PreparedOutcome::Invalid(drafts) if drafts.len() == 1));The caller’s orchestration policy records missing inputs and failed
prerequisites as skipped ValidationOutcome values.
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.
Valid
Input is valid.
Invalid(Vec<ViolationDraft>)
Input is invalid with draft violations.
Tuple Fields
§
0: Vec<ViolationDraft>One or more safe draft violations produced by the validator.
Implementations§
Source§impl PreparedOutcome
impl PreparedOutcome
Sourcepub fn invalid(
violations: Vec<ViolationDraft>,
) -> Result<Self, ValidationOutcomeError>
pub fn invalid( violations: Vec<ViolationDraft>, ) -> Result<Self, ValidationOutcomeError>
Creates an invalid prepared outcome with one or more violation drafts.
§Parameters
violations: Draft violations to include in the outcome.
§Returns
The invalid prepared outcome containing violations.
§Errors
Returns ValidationOutcomeError::EmptyViolations when violations is
empty.
Sourcepub fn into_bound(
self,
rule_id: ValidatorId,
) -> Result<ValidationOutcome, ValidationOutcomeError>
pub fn into_bound( self, rule_id: ValidatorId, ) -> Result<ValidationOutcome, ValidationOutcomeError>
Attaches a bound rule identity to draft violations.
§Parameters
rule_id: Identity of the rule that produced these violations.
§Returns
The corresponding bound validation outcome.
§Errors
Returns ValidationOutcomeError::EmptyViolations when an invalid
result has no drafts.
Trait Implementations§
Source§impl Debug for PreparedOutcome
impl Debug for PreparedOutcome
impl Eq for PreparedOutcome
Source§impl PartialEq for PreparedOutcome
impl PartialEq for PreparedOutcome
impl StructuralPartialEq for PreparedOutcome
Auto Trait Implementations§
impl Forget for PreparedOutcome
impl Freeze for PreparedOutcome
impl Move for PreparedOutcome
impl RefUnwindSafe for PreparedOutcome
impl Send for PreparedOutcome
impl Sync for PreparedOutcome
impl Unpin for PreparedOutcome
impl UnsafeUnpin for PreparedOutcome
impl UnwindSafe for PreparedOutcome
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