pub struct ExecutableCompensation {
pub action: CompensationAction,
/* private fields */
}Expand description
Extended compensation action with undo function support.
This extends the base CompensationAction with executable undo logic. The base type is serializable for audit logs, while this type adds runtime execution capabilities.
Fields§
§action: CompensationActionBase compensation action
Implementations§
Source§impl ExecutableCompensation
impl ExecutableCompensation
Sourcepub fn new(action: CompensationAction) -> Self
pub fn new(action: CompensationAction) -> Self
Creates a new ExecutableCompensation from an action.
Sourcepub fn with_undo<F>(description: impl Into<String>, undo_fn: F) -> Self
pub fn with_undo<F>(description: impl Into<String>, undo_fn: F) -> Self
Creates an UndoFunction compensation with the given undo function.
Sourcepub fn skip(description: impl Into<String>) -> Self
pub fn skip(description: impl Into<String>) -> Self
Creates a Skip compensation (no undo needed).
Sourcepub fn retry(description: impl Into<String>) -> Self
pub fn retry(description: impl Into<String>) -> Self
Creates a Retry compensation (recommends retry instead of undo).
Sourcepub fn execute(&self, context: &TaskContext) -> Result<TaskResult, TaskError>
pub fn execute(&self, context: &TaskContext) -> Result<TaskResult, TaskError>
Executes the compensation action.
Trait Implementations§
Source§impl Clone for ExecutableCompensation
impl Clone for ExecutableCompensation
Source§fn clone(&self) -> ExecutableCompensation
fn clone(&self) -> ExecutableCompensation
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 From<ExecutableCompensation> for CompensationAction
impl From<ExecutableCompensation> for CompensationAction
Source§fn from(exec: ExecutableCompensation) -> Self
fn from(exec: ExecutableCompensation) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ExecutableCompensation
impl !RefUnwindSafe for ExecutableCompensation
impl Send for ExecutableCompensation
impl Sync for ExecutableCompensation
impl Unpin for ExecutableCompensation
impl UnsafeUnpin for ExecutableCompensation
impl !UnwindSafe for ExecutableCompensation
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<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