pub enum VerificationResult {
Ok,
Unauthorized,
}Expand description
Result of a secret / credential verification operation.
This enum is used throughout the authentication pipeline (hash verification, credential repository checks, login services) to distinguish a successful verification from an unauthorized outcome without revealing why it failed (e.g. wrong password vs. unknown user) when higher layers deliberately collapse those states to resist user enumeration.
§Semantics
VerificationResult::Ok— Supplied value matched the stored/expected secret.VerificationResult::Unauthorized— Value did not match, or the subject/identity was intentionally treated as non-existent/mismatched for security uniformity.
§Conversions
VerificationResult::from(bool)mapstrue -> Ok,false -> Unauthorized.bool::from(VerificationResult)returnstrueforOk,falseotherwise.
§When to Use
Prefer this over Result<bool, E> when:
- You want an explicit success vs. unauthorized domain signal
- Errors/exceptions are reserved strictly for infrastructural failures
§Side‑Channel Guidance
Combine it with constant‑time hash verification and unified handling to avoid exposing whether an identifier exists.
§Example
use axum_gate::verification_result::VerificationResult;
fn check(match_flag: bool) -> VerificationResult {
VerificationResult::from(match_flag)
}
assert_eq!(check(true), VerificationResult::Ok);
assert_eq!(check(false), VerificationResult::Unauthorized);Variants§
Ok
The verification succeeded (value matched).
The supplied value failed verification (non-match / unauthorized).
Trait Implementations§
Source§impl Clone for VerificationResult
impl Clone for VerificationResult
Source§fn clone(&self) -> VerificationResult
fn clone(&self) -> VerificationResult
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 VerificationResult
impl Debug for VerificationResult
Source§impl From<VerificationResult> for bool
impl From<VerificationResult> for bool
Source§fn from(result: VerificationResult) -> Self
fn from(result: VerificationResult) -> Self
Converts to this type from the input type.
Source§impl From<bool> for VerificationResult
impl From<bool> for VerificationResult
Source§impl PartialEq for VerificationResult
impl PartialEq for VerificationResult
impl Copy for VerificationResult
impl Eq for VerificationResult
impl StructuralPartialEq for VerificationResult
Auto Trait Implementations§
impl Freeze for VerificationResult
impl RefUnwindSafe for VerificationResult
impl Send for VerificationResult
impl Sync for VerificationResult
impl Unpin for VerificationResult
impl UnwindSafe for VerificationResult
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<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
Compare self to
key and return true if they are equal.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
Compare self to
key and return true if they are equal.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