pub trait Transaction<Err> {
// Required methods
async fn execute<OpIn: Clone + 'static, OpOut: Clone + 'static>(
&mut self,
operation: impl Operation<In = OpIn, Out = OpOut, Err = Err> + 'static,
input: OpIn,
) -> Result<OpOut, Err>;
async fn fail(&mut self, error: Err) -> Result<(), Err>;
async fn run<Out: 'static>(
f: impl for<'a> FnOnce(&'a mut Self) -> LocalBoxFuture<'a, Result<Out, Err>>,
) -> TransactionResult<Out, Err>;
}Expand description
A unified interface for the different types of transactions. Using it can make the code easier to switch between different transactional guarantees but is more constrained in terms of error types.
Required Methods§
async fn execute<OpIn: Clone + 'static, OpOut: Clone + 'static>( &mut self, operation: impl Operation<In = OpIn, Out = OpOut, Err = Err> + 'static, input: OpIn, ) -> Result<OpOut, Err>
async fn fail(&mut self, error: Err) -> Result<(), Err>
async fn run<Out: 'static>( f: impl for<'a> FnOnce(&'a mut Self) -> LocalBoxFuture<'a, Result<Out, Err>>, ) -> TransactionResult<Out, Err>
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.