Skip to main content

Operation

Trait Operation 

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

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

Represents a compensable operation of the transaction.

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

Required Associated Types§

Required Methods§

Source

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

Executes the operation which may fail with a domain error

Source

async 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".

Implementors§