pub trait HoprDbGeneralModelOperations {
// Required methods
fn conn(&self, target_db: TargetDb) -> &DatabaseConnection;
fn begin_transaction_in_db<'life0, 'async_trait>(
&'life0 self,
target: TargetDb,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn begin_transaction<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn nest_transaction_in_db<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: OptTx<'life1>,
target_db: TargetDb,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn nest_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: OptTx<'life1>,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Required Methods§
Sourcefn conn(&self, target_db: TargetDb) -> &DatabaseConnection
fn conn(&self, target_db: TargetDb) -> &DatabaseConnection
Returns reference to the database connection.
Can be used in case transaction is not needed, but
users should aim to use HoprDbGeneralModelOperations::begin_transaction
and HoprDbGeneralModelOperations::nest_transaction
as much as possible.
Sourcefn begin_transaction_in_db<'life0, 'async_trait>(
&'life0 self,
target: TargetDb,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin_transaction_in_db<'life0, 'async_trait>(
&'life0 self,
target: TargetDb,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Creates a new transaction.
Provided Methods§
Sourcefn begin_transaction<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn begin_transaction<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Same as HoprDbGeneralModelOperations::begin_transaction_in_db
with default TargetDb.
Sourcefn nest_transaction_in_db<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: OptTx<'life1>,
target_db: TargetDb,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn nest_transaction_in_db<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: OptTx<'life1>,
target_db: TargetDb,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Creates a nested transaction inside the given transaction.
If None
is given, behaves exactly as HoprDbGeneralModelOperations::begin_transaction
.
This method is useful for creating APIs that should be agnostic whether they are being run from an existing transaction or without it (via OptTx).
If tx
is Some
, the target_db
must match with the one in tx
. In other words,
nesting across different databases is forbidden and the method will panic.
Sourcefn nest_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: OptTx<'life1>,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn nest_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: OptTx<'life1>,
) -> Pin<Box<dyn Future<Output = Result<OpenTransaction>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Same as HoprDbGeneralModelOperations::nest_transaction_in_db
with default TargetDb.