Skip to main content

Transaction

Trait Transaction 

Source
pub trait Transaction: QueryExecutor {
    type Nested<'a>: Transaction<Error = Self::Error, Row = Self::Row> + 'a
       where Self: 'a;

    // Required methods
    fn transaction(
        &mut self,
    ) -> impl Future<Output = Result<Self::Nested<'_>, Self::Error>> + Send;
    fn commit(self) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn rollback(self) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
Expand description

Trait for a database transaction. Extends QueryExecutor with commit/rollback and nested transaction (savepoint) support. Dropping without calling commit() should rollback the transaction.

Required Associated Types§

Source

type Nested<'a>: Transaction<Error = Self::Error, Row = Self::Row> + 'a where Self: 'a

Required Methods§

Source

fn transaction( &mut self, ) -> impl Future<Output = Result<Self::Nested<'_>, Self::Error>> + Send

Begin a nested transaction (savepoint).

Source

fn commit(self) -> impl Future<Output = Result<(), Self::Error>> + Send

Commit this transaction.

Source

fn rollback(self) -> impl Future<Output = Result<(), Self::Error>> + Send

Rollback this 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 Transaction for PgTransaction<'_>

Source§

type Nested<'a> = PgTransaction<'a> where Self: 'a