Skip to main content

CasSuccess

Enum CasSuccess 

Source
pub enum CasSuccess<T, R> {
    Updated {
        previous: Arc<T>,
        current: Arc<T>,
        output: R,
        context: CasContext,
    },
    Finished {
        current: Arc<T>,
        output: R,
        context: CasContext,
    },
}
Expand description

Successful result returned by crate::CasExecutor.

Variants§

§

Updated

The executor installed a new state by compare-and-swap.

Fields

§previous: Arc<T>

Previous state observed by the successful attempt.

§current: Arc<T>

Current state after the successful update.

§output: R

Business output returned by the operation.

§context: CasContext

Retry context captured when the flow completed.

§

Finished

The executor finished successfully without writing a new state.

Fields

§current: Arc<T>

Current state that remained installed.

§output: R

Business output returned by the operation.

§context: CasContext

Retry context captured when the flow completed.

Implementations§

Source§

impl<T, R> CasSuccess<T, R>

Source

pub fn is_updated(&self) -> bool

Returns whether this success performed a write.

§Returns

true for CasSuccess::Updated, false for CasSuccess::Finished.

Source

pub fn previous(&self) -> Option<&Arc<T>>

Returns the previous state when a write occurred.

§Returns

Some(&Arc<T>) for CasSuccess::Updated, or None when no write occurred.

Source

pub fn current(&self) -> &Arc<T>

Returns the current state after success.

§Returns

Shared reference to the current state.

Source

pub fn output(&self) -> &R

Returns the business output.

§Returns

Shared reference to the business output.

Source

pub fn into_output(self) -> R

Consumes the success result and returns the business output.

§Returns

The owned business output.

Source

pub fn context(&self) -> CasContext

Returns the retry context captured at success.

§Returns

Retry context for the completed flow.

Source

pub fn attempts(&self) -> u32

Returns the number of attempts that were executed.

§Returns

One-based attempt count.

Trait Implementations§

Source§

impl<T: Clone, R: Clone> Clone for CasSuccess<T, R>

Source§

fn clone(&self) -> CasSuccess<T, R>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, R: Debug> Debug for CasSuccess<T, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: PartialEq, R: PartialEq> PartialEq for CasSuccess<T, R>

Source§

fn eq(&self, other: &CasSuccess<T, R>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq, R: Eq> Eq for CasSuccess<T, R>

Source§

impl<T, R> StructuralPartialEq for CasSuccess<T, R>

Auto Trait Implementations§

§

impl<T, R> Freeze for CasSuccess<T, R>
where R: Freeze,

§

impl<T, R> RefUnwindSafe for CasSuccess<T, R>

§

impl<T, R> Send for CasSuccess<T, R>
where R: Send, T: Sync + Send,

§

impl<T, R> Sync for CasSuccess<T, R>
where R: Sync, T: Sync + Send,

§

impl<T, R> Unpin for CasSuccess<T, R>
where R: Unpin,

§

impl<T, R> UnsafeUnpin for CasSuccess<T, R>
where R: UnsafeUnpin,

§

impl<T, R> UnwindSafe for CasSuccess<T, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoResult<T> for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.