hopr_db_sql

Trait HoprDbGeneralModelOperations

Source
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§

Source

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.

Source

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§

Source

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,

Source

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.

Source

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,

Implementors§