pub enum ValidationOutcome {
Ok {
contract: TokenContract,
consumed: bool,
effective_ttl: Duration,
},
Rejected(TokenLifecycleError),
}Expand description
Outcome of a TokenValidator::validate call.
The validator always returns a ValidationOutcome — never
a Result — so the caller can branch on the outcome
without unwrapping. The error path embeds the structured
InvalidationReason for diagnostic routing.
§Example
use stygian_charon::token_lifecycle::{
ChallengeClass, TokenContract, TokenPolicyTable, TokenValidator,
ValidationOutcome,
};
use stygian_charon::vendor_classifier::VendorId;
use std::time::Duration;
let validator = TokenValidator::with_defaults(TokenPolicyTable::with_builtin_defaults());
let contract = TokenContract {
token_id: "x".to_string(),
issued_at_unix_secs: 0,
ttl: Duration::from_mins(5),
nonce: "n".to_string(),
vendor_family: VendorId::Cloudflare,
challenge_class: ChallengeClass::Interstitial,
single_use: true,
bound_session: None,
description: String::new(),
};
let outcome = validator.validate(&contract, None, 60);
assert!(matches!(outcome, ValidationOutcome::Ok { .. }));Variants§
Ok
Validator accepted the submission.
Fields
§
contract: TokenContractContract that was accepted (with the TTL the
validator actually applied — possibly clamped to
the per-vendor max_ttl).
Rejected(TokenLifecycleError)
Validator rejected the submission. The error carries
the structured InvalidationReason and a
human-readable message suitable for operator logs.
Implementations§
Source§impl ValidationOutcome
impl ValidationOutcome
Sourcepub const fn is_ok(&self) -> bool
pub const fn is_ok(&self) -> bool
true when the validator accepted the submission.
§Example
use stygian_charon::token_lifecycle::{ValidationOutcome};
let outcome = ValidationOutcome::Ok {
contract: stygian_charon::token_lifecycle::TokenContract {
token_id: "x".to_string(),
issued_at_unix_secs: 0,
ttl: std::time::Duration::from_mins(1),
nonce: "n".to_string(),
vendor_family: stygian_charon::vendor_classifier::VendorId::Unknown,
challenge_class: stygian_charon::token_lifecycle::ChallengeClass::None,
single_use: false,
bound_session: None,
description: String::new(),
},
consumed: true,
effective_ttl: std::time::Duration::from_mins(1),
};
assert!(outcome.is_ok());Sourcepub const fn is_rejected(&self) -> bool
pub const fn is_rejected(&self) -> bool
true when the validator rejected the submission.
Sourcepub const fn error(&self) -> Option<&TokenLifecycleError>
pub const fn error(&self) -> Option<&TokenLifecycleError>
Borrow the underlying error when Rejected.
Sourcepub fn invalidation_kind(&self) -> Option<InvalidationKind>
pub fn invalidation_kind(&self) -> Option<InvalidationKind>
Invalidation kind when Rejected.
Trait Implementations§
Source§impl Clone for ValidationOutcome
impl Clone for ValidationOutcome
Source§fn clone(&self) -> ValidationOutcome
fn clone(&self) -> ValidationOutcome
Returns a duplicate of the value. Read more
1.0.0 · 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 ValidationOutcome
impl Debug for ValidationOutcome
Source§impl PartialEq for ValidationOutcome
impl PartialEq for ValidationOutcome
impl Eq for ValidationOutcome
impl StructuralPartialEq for ValidationOutcome
Auto Trait Implementations§
impl Freeze for ValidationOutcome
impl RefUnwindSafe for ValidationOutcome
impl Send for ValidationOutcome
impl Sync for ValidationOutcome
impl Unpin for ValidationOutcome
impl UnsafeUnpin for ValidationOutcome
impl UnwindSafe for ValidationOutcome
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.