pub fn run<T, E, F>(&mut self, f: F) -> Result<T, E>
    where
        F: FnOnce(&mut C) -> Result<T, E>,
        E: From<Error>,
    {
        let mut query_builder = <Pg as Backend>::QueryBuilder::default();
        self.to_sql(&mut query_builder)?;
        let sql = query_builder.finish();

        AnsiTransactionManager::begin_transaction_sql(&mut *self.connection, &sql)?;
        match f(&mut *self.connection) {
            Ok(value) => {
                AnsiTransactionManager::commit_transaction(&mut *self.connection)?;
                Ok(value)
            }
            Err(e) => {
                AnsiTransactionManager::rollback_transaction(&mut *self.connection)
                    .map_err(|e| Error::RollbackError(Box::new(e)))?;
                Err(e)
            }
        }
    }
/// Runs the given function inside of the transaction
/// with the parameters given to this builder.
///
/// This function executes the provided closure `f` inside a database
/// transaction. If there is already an open transaction for the current
/// connection it will return an error. The connection is commited if
/// the closure returns `Ok(_)`, it will be rolled back if it returns `Err(_)`.
/// For both cases the original result value will be returned from this function.
///
/// If the transaction fails to commit due to a `SerializationFailure` or a
/// `ReadOnlyTransaction` a rollback will be attempted. In this case a
/// [`Error::CommitTransactionFailed`](crate::result::Error::CommitTransactionFailed)
/// error is returned, which contains details about the original error and
/// the success of the rollback attempt.
/// If the rollback failed the connection should be considered broken
/// as it contains a uncommitted unabortable open transaction. Any further
/// interaction with the transaction system will result in an returned error
/// in this cases.
///
/// If the closure returns an `Err(_)` and the rollback fails the function
/// will return a [`Error::RollbackError`](crate::result::Error::RollbackError)
/// wrapping the error generated by the rollback operation instead.
/// In this case the connection should be considered broken as it contains
/// an unabortable open transaction.
Runs the given function inside of the transaction
with the parameters given to this builder.

This function executes the provided closure `f` inside a database
transaction. If there is already an open transaction for the current
connection it will return an error. The connection is commited if
the closure returns `Ok(_)`, it will be rolled back if it returns `Err(_)`.
For both cases the original result value will be returned from this function.

If the transaction fails to commit due to a `SerializationFailure` or a
`ReadOnlyTransaction` a rollback will be attempted.


Runs the given function inside of the transaction with the parameters given to this builder . This function executes the provided closure ` f ` inside a database transaction . If there is already an open transaction for the current connection it will return an error . The connection is commited if the closure returns ` Ok ( _ ) ` it will be rolled back if it returns ` Err ( _ ) ` . For both cases the original result value will be returned from this function . If the transaction fails to commit due to a ` SerializationFailure ` or a ` ReadOnlyTransaction ` a rollback will be attempted .
pub fn run<T, E, F>(&mut self, f: F) -> Result<T, E>
    where
        F: FnOnce(&mut C) -> Result<T, E>,
        E: From<Error>,
    {
        let mut query_builder = <Pg as Backend>::QueryBuilder::default();
        self.to_sql(&mut query_builder)?;
        let sql = query_builder.finish();
        AnsiTransactionManager::begin_transaction_sql(&mut *self.connection, &sql)?;
        match f(&mut *self.connection) {
            Ok(value) => {
                AnsiTransactionManager::commit_transaction(&mut *self.connection)?;
                Ok(value)
            }
            Err(e) => {
                AnsiTransactionManager::rollback_transaction(&mut *self.connection)
                    .map_err(|e| Error::RollbackError(Box::new(e)))?;
                Err(e)
            }
        }
    }
pub fn run < T , E , F > ( & mut self , f : F ) -> Result < T , E > where F : FnOnce ( & mut C ) -> Result < T , E > , E : From < Error > , { let mut query_builder = < Pg as Backend > :: QueryBuilder :: default ( ) ; self . to_sql ( & mut query_builder ) ? ; let sql = query_builder . finish ( ) ; AnsiTransactionManager :: begin_transaction_sql ( & mut * self . connection , & sql ) ? ; match f ( & mut * self . connection ) { Ok ( value ) => { AnsiTransactionManager :: commit_transaction ( & mut * self . connection ) ? ; Ok ( value ) } Err ( e ) => { AnsiTransactionManager :: rollback_transaction ( & mut * self . connection ) . map_err ( | e | Error :: RollbackError ( Box :: new ( e ) ) ) ? ; Err ( e ) } } }
Runs the given function inside of the transaction
with the parameters given to this builder.
Runs the given function inside of the transaction with the parameters given to this builder .
&mut self
f
F
&mut self
f
F