pub trait Database {
// Required methods
async fn connection(
&mut self,
) -> Result<&mut RawPgConnection, DatabaseError>;
async fn begin_transaction<'d>(
&'d mut self,
) -> Result<TransactedDb<'d>, DatabaseError>;
}Expand description
Provides access to a connection. Should be called by extension traits but not from application code.
Usually we don’t need to use this directly, so prefer underscore for imports.
Required Methods§
Sourceasync fn connection(&mut self) -> Result<&mut RawPgConnection, DatabaseError>
async fn connection(&mut self) -> Result<&mut RawPgConnection, DatabaseError>
Acquires a new connection from the pool.
Sourceasync fn begin_transaction<'d>(
&'d mut self,
) -> Result<TransactedDb<'d>, DatabaseError>
async fn begin_transaction<'d>( &'d mut self, ) -> Result<TransactedDb<'d>, DatabaseError>
Starts a new transaction, acquiring a fresh connection from the pool Once a transaction has been started, it is the callers’ responsibility to make changes permanent by committing it. If the transaction is dropped without being committed, all changes are rolled back.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".