pub trait TransactionManager<Conn: Connection> {
    type TransactionStateData;

    fn begin_transaction(conn: &mut Conn) -> QueryResult<()>;
    fn rollback_transaction(conn: &mut Conn) -> QueryResult<()>;
    fn commit_transaction(conn: &mut Conn) -> QueryResult<()>;

    fn transaction<F, R, E>(conn: &mut Conn, callback: F) -> Result<R, E>
    where
        F: FnOnce(&mut Conn) -> Result<R, E>,
        E: From<Error>
, { ... } }
Expand description

Manages the internal transaction state for a connection.

You will not need to interact with this trait, unless you are writing an implementation of Connection.

Required Associated Types

Data stored as part of the connection implementation to track the current transaction state of a connection

Required Methods

Begin a new transaction or savepoint

If the transaction depth is greater than 0, this should create a savepoint instead. This function is expected to increment the transaction depth by 1.

Rollback the inner-most transaction or savepoint

If the transaction depth is greater than 1, this should rollback to the most recent savepoint. This function is expected to decrement the transaction depth by 1.

Commit the inner-most transaction or savepoint

If the transaction depth is greater than 1, this should release the most recent savepoint. This function is expected to decrement the transaction depth by 1.

Provided Methods

Executes the given function inside of a database transaction

Each implementation of this function needs to fulfill the documented behaviour of Connection::transaction

Implementors