pub trait Transaction<Err> {
// Required methods
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>;
fn fail(&mut self, error: Err) -> Result<(), Err>;
fn run<Out>(
f: impl FnOnce(&mut Self) -> 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§
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>
fn fail(&mut self, error: Err) -> Result<(), Err>
fn run<Out>( f: impl FnOnce(&mut Self) -> 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.