pub enum CasAttemptFailure<T, E> {
Conflict {
current: Arc<T>,
},
Retry {
current: Arc<T>,
error: E,
},
Abort {
current: Arc<T>,
error: E,
},
Timeout {
current: Arc<T>,
},
}Expand description
Failure produced by one CAS attempt.
Variants§
Conflict
Compare-and-swap failed because another writer changed the state first.
Retry
Business logic requested another attempt.
Abort
Business logic aborted the CAS flow.
Timeout
One async attempt exceeded the configured timeout.
Implementations§
Source§impl<T, E> CasAttemptFailure<T, E>
impl<T, E> CasAttemptFailure<T, E>
Sourcepub fn current(&self) -> &Arc<T>
pub fn current(&self) -> &Arc<T>
Returns the state snapshot associated with this failure.
§Returns
Shared reference to the current state.
Sourcepub fn kind(&self) -> CasAttemptFailureKind
pub fn kind(&self) -> CasAttemptFailureKind
Returns the lightweight kind of this attempt failure.
§Returns
The CasAttemptFailureKind matching this failure variant.
Sourcepub fn error(&self) -> Option<&E>
pub fn error(&self) -> Option<&E>
Returns the business error when this failure carries one.
§Returns
Some(&E) for CasAttemptFailure::Retry and
CasAttemptFailure::Abort, or None otherwise.
Sourcepub fn is_conflict(&self) -> bool
pub fn is_conflict(&self) -> bool
Returns whether this failure is a compare-and-swap conflict.
§Returns
true for CasAttemptFailure::Conflict.
Sourcepub fn is_retry(&self) -> bool
pub fn is_retry(&self) -> bool
Returns whether this failure is a retryable business error.
§Returns
true for CasAttemptFailure::Retry.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Returns whether this failure came from an async timeout.
§Returns
true for CasAttemptFailure::Timeout.
Trait Implementations§
Source§impl<T: Clone, E: Clone> Clone for CasAttemptFailure<T, E>
impl<T: Clone, E: Clone> Clone for CasAttemptFailure<T, E>
Source§fn clone(&self) -> CasAttemptFailure<T, E>
fn clone(&self) -> CasAttemptFailure<T, E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more