pub trait TransactionHandler<DB>: Send + Sync{
type Item;
type Error: From<DB::Error> + Send + Sync;
// Required method
fn execute<'life0, 'async_trait>(
self,
ctx: &'life0 mut TestContext<DB>,
) -> Pin<Box<dyn Future<Output = Result<Self::Item, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn execute_standalone<'async_trait>(
self,
backend: DB,
) -> Pin<Box<dyn Future<Output = Result<Self::Item, Self::Error>> + Send + 'async_trait>>
where Self: Sized + 'async_trait { ... }
fn and_then<F, B>(self, f: F) -> AndThenHandler<DB, Self, B, F>
where Self: Sized,
B: TransactionHandler<DB, Error = Self::Error> + Send + Sync,
F: FnOnce(Self::Item) -> B + Send + Sync + 'static { ... }
fn setup<S, Fut, E>(
self,
setup_fn: S,
) -> impl TransactionHandler<DB, Item = (), Error = Self::Error>
where Self: Sized,
E: From<DB::Error> + From<Self::Error> + Send + Sync,
Fut: Future<Output = Result<(), DB::Error>> + Send + 'static,
S: FnOnce(&mut <DB::Pool as DatabasePool>::Connection) -> Fut + Send + Sync + 'static { ... }
fn with_transaction<F, Fut, E>(
self,
transaction_fn: F,
) -> impl TransactionHandler<DB, Item = (), Error = Self::Error>
where Self: Sized,
E: From<DB::Error> + From<Self::Error> + Send + Sync,
Fut: Future<Output = Result<(), DB::Error>> + Send + 'static,
F: FnOnce(&mut <DB as DatabaseBackend>::Connection) -> Fut + Send + Sync + 'static { ... }
fn with_db_transaction<F, Fut, E>(
self,
db: TestDatabaseInstance<DB>,
transaction_fn: F,
) -> impl TransactionHandler<DB, Item = TestContext<DB>, Error = Self::Error>
where Self: Sized,
E: From<DB::Error> + From<Self::Error> + Send + Sync,
Fut: Future<Output = Result<(), DB::Error>> + Send + 'static,
F: FnOnce(&mut <DB as DatabaseBackend>::Connection) -> Fut + Send + Sync + 'static { ... }
fn run_with_database<'async_trait>(
self,
backend: DB,
) -> Pin<Box<dyn Future<Output = Result<TestContext<DB>, Self::Error>> + Send + 'async_trait>>
where Self: Sized + 'async_trait { ... }
}
Expand description
A trait for handlers that can work with transactions
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn execute_standalone<'async_trait>(
self,
backend: DB,
) -> Pin<Box<dyn Future<Output = Result<Self::Item, Self::Error>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
fn execute_standalone<'async_trait>(
self,
backend: DB,
) -> Pin<Box<dyn Future<Output = Result<Self::Item, Self::Error>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
Execute this handler with a new context
This is a convenience method that creates a new context using the provided database backend and then executes the handler with it.
Sourcefn and_then<F, B>(self, f: F) -> AndThenHandler<DB, Self, B, F>
fn and_then<F, B>(self, f: F) -> AndThenHandler<DB, Self, B, F>
Chain two handlers together, where the second handler may depend on the result of the first
Sourcefn setup<S, Fut, E>(
self,
setup_fn: S,
) -> impl TransactionHandler<DB, Item = (), Error = Self::Error>
fn setup<S, Fut, E>( self, setup_fn: S, ) -> impl TransactionHandler<DB, Item = (), Error = Self::Error>
Add a setup operation to this handler
Sourcefn with_transaction<F, Fut, E>(
self,
transaction_fn: F,
) -> impl TransactionHandler<DB, Item = (), Error = Self::Error>
fn with_transaction<F, Fut, E>( self, transaction_fn: F, ) -> impl TransactionHandler<DB, Item = (), Error = Self::Error>
Add a transaction operation to this handler
Sourcefn with_db_transaction<F, Fut, E>(
self,
db: TestDatabaseInstance<DB>,
transaction_fn: F,
) -> impl TransactionHandler<DB, Item = TestContext<DB>, Error = Self::Error>
fn with_db_transaction<F, Fut, E>( self, db: TestDatabaseInstance<DB>, transaction_fn: F, ) -> impl TransactionHandler<DB, Item = TestContext<DB>, Error = Self::Error>
Create a database transaction handler from this handler
Sourcefn run_with_database<'async_trait>(
self,
backend: DB,
) -> Pin<Box<dyn Future<Output = Result<TestContext<DB>, Self::Error>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
fn run_with_database<'async_trait>(
self,
backend: DB,
) -> Pin<Box<dyn Future<Output = Result<TestContext<DB>, Self::Error>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
Run this handler with a new database instance