pub trait TransactionRunner<'p, Repos>: Sized {
type Tx: TransactionOps;
type DbError: StdError + Send + Sync;
// Required method
async fn run<F, Fut, T, E>(self, f: F) -> Result<T, E>
where F: FnOnce(TransactionContext<'_, Self::Tx, Repos>) -> Fut + Send,
Fut: Future<Output = Result<T, E>> + Send,
E: From<TransactionError<Self::DbError>>;
}Expand description
Trait for executing operations within a transaction.
This trait is implemented on Transaction with specific repository
combinations, enabling type-safe execution.
Required Associated Types§
Sourcetype Tx: TransactionOps
type Tx: TransactionOps
Transaction type.
Required Methods§
Sourceasync fn run<F, Fut, T, E>(self, f: F) -> Result<T, E>where
F: FnOnce(TransactionContext<'_, Self::Tx, Repos>) -> Fut + Send,
Fut: Future<Output = Result<T, E>> + Send,
E: From<TransactionError<Self::DbError>>,
async fn run<F, Fut, T, E>(self, f: F) -> Result<T, E>where
F: FnOnce(TransactionContext<'_, Self::Tx, Repos>) -> Fut + Send,
Fut: Future<Output = Result<T, E>> + Send,
E: From<TransactionError<Self::DbError>>,
Execute a closure within the transaction.
Automatically commits on Ok, rolls back on Err or panic.
§Type Parameters
F— Closure typeFut— Future returned by closureT— Success typeE— Error type (must be convertible from database error)
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.