Trait Operation

Source
pub trait Operation: Clone {
    type In: Clone;
    type Out: Clone;
    type Err: Clone;

    // Required methods
    fn execute(&self, input: Self::In) -> Result<Self::Out, Self::Err>;
    fn compensate(
        &self,
        input: Self::In,
        result: Self::Out,
    ) -> Result<(), Self::Err>;
}
Expand description

Represents an atomic operation of the transaction which has a rollback action.

Implement this trait and use it within a transaction block. Operations can also be constructed from closures using operation.

Required Associated Types§

Required Methods§

Source

fn execute(&self, input: Self::In) -> Result<Self::Out, Self::Err>

Executes the operation which may fail with a domain error

Source

fn compensate( &self, input: Self::In, result: Self::Out, ) -> Result<(), Self::Err>

Executes a compensation action for the operation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§