Skip to main content

Transaction

Trait Transaction 

Source
pub trait Transaction {
    type Error: Error;
    type Permit;

    // Required methods
    fn begin(&self) -> impl Future<Output = Result<Self::Permit, Self::Error>>;
    fn rollback(
        &self,
        permit: Self::Permit,
    ) -> impl Future<Output = Result<(), Self::Error>>;
    fn commit(
        &self,
        permit: Self::Permit,
    ) -> impl Future<Output = Result<(), Self::Error>>;
}
Expand description

Traits to implement database transaction provider.

To guard against sharing transactions unknowingly across unrelated database queries, a concept of a “permit” was introduced which does not protect from misuse but helps to make “holding” a transaction explicit.

Required Associated Types§

Required Methods§

Source

fn begin(&self) -> impl Future<Output = Result<Self::Permit, Self::Error>>

Begins a transaction.

Source

fn rollback( &self, permit: Self::Permit, ) -> impl Future<Output = Result<(), Self::Error>>

Rolls back the transaction and with that all uncommitted changes.

Source

fn commit( &self, permit: Self::Permit, ) -> impl Future<Output = Result<(), Self::Error>>

Commits the transaction.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Transaction for SqliteStore

Available on crate feature sqlite only.
Source§

impl<E> Transaction for SqliteSpacesStore<E>

Available on crate features spaces and sqlite only.