Trait diesel::connection::TransactionManager[][src]

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 get_transaction_depth(conn: &mut Conn) -> u32; }

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.

Associated Types

type TransactionStateData[src]

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

Loading content...

Required methods

fn begin_transaction(conn: &mut Conn) -> QueryResult<()>[src]

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.

fn rollback_transaction(conn: &mut Conn) -> QueryResult<()>[src]

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.

fn commit_transaction(conn: &mut Conn) -> QueryResult<()>[src]

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.

fn get_transaction_depth(conn: &mut Conn) -> u32[src]

Fetch the current transaction depth

Used to ensure that begin_test_transaction is not called when already inside of a transaction.

Loading content...

Implementors

impl<Conn> TransactionManager<Conn> for AnsiTransactionManager where
    Conn: Connection<TransactionManager = Self>,
    Conn::Backend: UsesAnsiSavepointSyntax
[src]

type TransactionStateData = Self

fn commit_transaction(conn: &mut Conn) -> QueryResult<()>[src]

If the transaction fails to commit due to a SerializationFailure or a ReadOnlyTransaction a rollback will be attempted. If the rollback succeeds, the original error will be returned, otherwise the error generated by the rollback will be returned. In the second case the connection should be considered broken as it contains a uncommitted unabortable open transaction.

Loading content...