pub trait TransactionManager<Conn: AsyncConnection>: Send {
type TransactionStateData;
// Required methods
fn begin_transaction<'life0, 'async_trait>(
conn: &'life0 mut Conn,
) -> Pin<Box<dyn Future<Output = QueryResult<()>> + Send + 'async_trait>>
where 'life0: 'async_trait;
fn rollback_transaction<'life0, 'async_trait>(
conn: &'life0 mut Conn,
) -> Pin<Box<dyn Future<Output = QueryResult<()>> + Send + 'async_trait>>
where 'life0: 'async_trait;
fn commit_transaction<'life0, 'async_trait>(
conn: &'life0 mut Conn,
) -> Pin<Box<dyn Future<Output = QueryResult<()>> + Send + 'async_trait>>
where 'life0: 'async_trait;
// Provided method
fn transaction<'a, 'life0, 'async_trait, F, R, E>(
conn: &'life0 mut Conn,
callback: F,
) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 'async_trait>>
where F: for<'r> FnOnce(&'r mut Conn) -> ScopedBoxFuture<'a, 'r, Result<R, E>> + Send + 'a + 'async_trait,
E: From<Error> + Send + 'async_trait,
R: Send + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Manages the internal transaction state for a connection.
You will not need to interact with this trait, unless you are writing an
implementation of AsyncConnection
.
Required Associated Types§
Sourcetype TransactionStateData
type TransactionStateData
Data stored as part of the connection implementation to track the current transaction state of a connection
Required Methods§
Sourcefn begin_transaction<'life0, 'async_trait>(
conn: &'life0 mut Conn,
) -> Pin<Box<dyn Future<Output = QueryResult<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
fn begin_transaction<'life0, 'async_trait>(
conn: &'life0 mut Conn,
) -> Pin<Box<dyn Future<Output = QueryResult<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
Begin a new transaction or savepoint
If the transaction depth is greater than 0, this should create a savepoint instead. This function is expected to increment the transaction depth by 1.
Sourcefn rollback_transaction<'life0, 'async_trait>(
conn: &'life0 mut Conn,
) -> Pin<Box<dyn Future<Output = QueryResult<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
fn rollback_transaction<'life0, 'async_trait>(
conn: &'life0 mut Conn,
) -> Pin<Box<dyn Future<Output = QueryResult<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
Rollback the inner-most transaction or savepoint
If the transaction depth is greater than 1, this should rollback to the most recent savepoint. This function is expected to decrement the transaction depth by 1.
Sourcefn commit_transaction<'life0, 'async_trait>(
conn: &'life0 mut Conn,
) -> Pin<Box<dyn Future<Output = QueryResult<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
fn commit_transaction<'life0, 'async_trait>(
conn: &'life0 mut Conn,
) -> Pin<Box<dyn Future<Output = QueryResult<()>> + Send + 'async_trait>>where
'life0: 'async_trait,
Commit the inner-most transaction or savepoint
If the transaction depth is greater than 1, this should release the most recent savepoint. This function is expected to decrement the transaction depth by 1.
Provided Methods§
Sourcefn transaction<'a, 'life0, 'async_trait, F, R, E>(
conn: &'life0 mut Conn,
callback: F,
) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 'async_trait>>where
F: for<'r> FnOnce(&'r mut Conn) -> ScopedBoxFuture<'a, 'r, Result<R, E>> + Send + 'a + 'async_trait,
E: From<Error> + Send + 'async_trait,
R: Send + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn transaction<'a, 'life0, 'async_trait, F, R, E>(
conn: &'life0 mut Conn,
callback: F,
) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 'async_trait>>where
F: for<'r> FnOnce(&'r mut Conn) -> ScopedBoxFuture<'a, 'r, Result<R, E>> + Send + 'a + 'async_trait,
E: From<Error> + Send + 'async_trait,
R: Send + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Executes the given function inside of a database transaction
Each implementation of this function needs to fulfill the documented
behaviour of AsyncConnection::transaction
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.
Implementors§
Source§impl<Conn> TransactionManager<Conn> for AnsiTransactionManagerwhere
Conn: AsyncConnection<TransactionManager = Self>,
impl<Conn> TransactionManager<Conn> for AnsiTransactionManagerwhere
Conn: AsyncConnection<TransactionManager = Self>,
Source§impl<T, C> TransactionManager<SyncConnectionWrapper<C>> for SyncTransactionManagerWrapper<T>where
SyncConnectionWrapper<C>: AsyncConnection,
C: Connection + 'static,
T: TransactionManager<C> + Send,
Available on crate feature sync-connection-wrapper
only.
impl<T, C> TransactionManager<SyncConnectionWrapper<C>> for SyncTransactionManagerWrapper<T>where
SyncConnectionWrapper<C>: AsyncConnection,
C: Connection + 'static,
T: TransactionManager<C> + Send,
sync-connection-wrapper
only.