Skip to main content

TransactionExt

Trait TransactionExt 

Source
pub trait TransactionExt {
    // Required methods
    fn transaction<'life0, 'async_trait, F, T, Fut>(
        &'life0 self,
        f: F,
    ) -> Pin<Box<dyn Future<Output = Result<T, FrameworkError>> + Send + 'async_trait>>
       where F: FnOnce(&DatabaseTransaction) -> Fut + Send + 'async_trait,
             Fut: Future<Output = Result<T, FrameworkError>> + Send + 'async_trait,
             T: Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn transaction_with<'life0, 'async_trait, F, T, Fut>(
        &'life0 self,
        isolation_level: IsolationLevel,
        f: F,
    ) -> Pin<Box<dyn Future<Output = Result<T, FrameworkError>> + Send + 'async_trait>>
       where F: FnOnce(&DatabaseTransaction) -> Fut + Send + 'async_trait,
             Fut: Future<Output = Result<T, FrameworkError>> + Send + 'async_trait,
             T: Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Extension trait for running transactions on a database connection

Required Methods§

Source

fn transaction<'life0, 'async_trait, F, T, Fut>( &'life0 self, f: F, ) -> Pin<Box<dyn Future<Output = Result<T, FrameworkError>> + Send + 'async_trait>>
where F: FnOnce(&DatabaseTransaction) -> Fut + Send + 'async_trait, Fut: Future<Output = Result<T, FrameworkError>> + Send + 'async_trait, T: Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Execute a closure within a transaction

§Example
use ferro_rs::database::{DB, TransactionExt};

DB::connection()?.transaction(|txn| async move {
    // Your transactional operations
    Ok(())
}).await?;
Source

fn transaction_with<'life0, 'async_trait, F, T, Fut>( &'life0 self, isolation_level: IsolationLevel, f: F, ) -> Pin<Box<dyn Future<Output = Result<T, FrameworkError>> + Send + 'async_trait>>
where F: FnOnce(&DatabaseTransaction) -> Fut + Send + 'async_trait, Fut: Future<Output = Result<T, FrameworkError>> + Send + 'async_trait, T: Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Execute a closure within a transaction with custom isolation level

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.

Implementations on Foreign Types§

Source§

impl TransactionExt for DatabaseConnection

Source§

fn transaction<'life0, 'async_trait, F, T, Fut>( &'life0 self, f: F, ) -> Pin<Box<dyn Future<Output = Result<T, FrameworkError>> + Send + 'async_trait>>
where F: FnOnce(&DatabaseTransaction) -> Fut + Send + 'async_trait, Fut: Future<Output = Result<T, FrameworkError>> + Send + 'async_trait, T: Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Source§

fn transaction_with<'life0, 'async_trait, F, T, Fut>( &'life0 self, isolation_level: IsolationLevel, f: F, ) -> Pin<Box<dyn Future<Output = Result<T, FrameworkError>> + Send + 'async_trait>>
where F: FnOnce(&DatabaseTransaction) -> Fut + Send + 'async_trait, Fut: Future<Output = Result<T, FrameworkError>> + Send + 'async_trait, T: Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Implementors§