Trait diesel::connection::Connection [] [src]

pub trait Connection: SimpleConnection + Sized {
    type Backend: Backend;
    fn establish(database_url: &str) -> ConnectionResult<Self>;

    fn transaction<T, E, F>(&self, f: F) -> TransactionResult<T, E> where F: FnOnce() -> Result<T, E> { ... }
    fn begin_test_transaction(&self) -> QueryResult<()> { ... }
    fn test_transaction<T, E, F>(&self, f: F) -> T where F: FnOnce() -> Result<T, E> { ... }
}

Associated Types

Required Methods

Establishes a new connection to the database at the given URL. The URL should be a valid connection string for a given backend. See the documentation for the specific backend for specifics.

Provided Methods

Executes the given function inside of a database transaction. When a transaction is already occurring, savepoints will be used to emulate a nested transaction.

If the function returns an Ok, that value will be returned. If the function returns an Err, TransactionError::UserReturnedError will be returned wrapping that value.

Creates a transaction that will never be committed. This is useful for tests. Panics if called while inside of a transaction.

Executes the given function inside a transaction, but does not commit it. Panics if the given function returns an Err.

Implementors