pub trait TransactionTrait {
type Transaction: ConnectionTrait + TransactionTrait + TransactionSession;
// Required methods
fn begin<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn begin_with_config<'life0, 'async_trait>(
&'life0 self,
isolation_level: Option<IsolationLevel>,
access_mode: Option<AccessMode>,
) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn transaction<'life0, 'async_trait, F, T, E>(
&'life0 self,
callback: F,
) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>>
where F: for<'c> FnOnce(&'c Self::Transaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'c>> + Send + 'async_trait,
T: Send + 'async_trait,
E: Display + Debug + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn transaction_with_config<'life0, 'async_trait, F, T, E>(
&'life0 self,
callback: F,
isolation_level: Option<IsolationLevel>,
access_mode: Option<AccessMode>,
) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>>
where F: for<'c> FnOnce(&'c Self::Transaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'c>> + Send + 'async_trait,
T: Send + 'async_trait,
E: Display + Debug + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Spawn database transaction
Required Associated Typesยง
Sourcetype Transaction: ConnectionTrait + TransactionTrait + TransactionSession
type Transaction: ConnectionTrait + TransactionTrait + TransactionSession
The concrete type for the transaction
Required Methodsยง
Sourcefn begin<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute SQL BEGIN transaction.
Returns a Transaction that can be committed or rolled back
Sourcefn begin_with_config<'life0, 'async_trait>(
&'life0 self,
isolation_level: Option<IsolationLevel>,
access_mode: Option<AccessMode>,
) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin_with_config<'life0, 'async_trait>(
&'life0 self,
isolation_level: Option<IsolationLevel>,
access_mode: Option<AccessMode>,
) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute SQL BEGIN transaction with isolation level and/or access mode.
Returns a Transaction that can be committed or rolled back
Sourcefn transaction<'life0, 'async_trait, F, T, E>(
&'life0 self,
callback: F,
) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>>
fn transaction<'life0, 'async_trait, F, T, E>( &'life0 self, callback: F, ) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>>
Execute the function inside a transaction. If the function returns an error, the transaction will be rolled back. If it does not return an error, the transaction will be committed.
Sourcefn transaction_with_config<'life0, 'async_trait, F, T, E>(
&'life0 self,
callback: F,
isolation_level: Option<IsolationLevel>,
access_mode: Option<AccessMode>,
) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>>
fn transaction_with_config<'life0, 'async_trait, F, T, E>( &'life0 self, callback: F, isolation_level: Option<IsolationLevel>, access_mode: Option<AccessMode>, ) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>>
Execute the function inside a transaction with isolation level and/or access mode. If the function returns an error, the transaction will be rolled back. If it does not return an error, the transaction will be committed.
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 TransactionTrait for DatabaseExecutor<'_>
impl TransactionTrait for DatabaseExecutor<'_>
Sourceยงimpl TransactionTrait for RestrictedConnection
Available on crate feature rbac only.
impl TransactionTrait for RestrictedConnection
rbac only.Sourceยงimpl TransactionTrait for RestrictedTransaction
Available on crate feature rbac only.
impl TransactionTrait for RestrictedTransaction
rbac only.