pub trait Connection {
type Exec<'c>: Executor<'c, Database = Any>
where Self: 'c;
// Required methods
fn executor<'c>(&'c mut self) -> Self::Exec<'c>;
fn driver(&self) -> Drivers;
}Expand description
A trait representing a database connection or transaction.
This trait abstracts over Database (pool) and Transaction types, allowing
the QueryBuilder to work seamlessly with both. It uses Generic Associated Types (GATs)
to handle the lifetimes of the executor references correctly.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<'a, T> Connection for &'a mut T
Implementation of Connection for any mutable reference to a type implementing Connection.
impl<'a, T> Connection for &'a mut T
Implementation of Connection for any mutable reference to a type implementing Connection.
This allows passing &mut Database or &mut Transaction where Connection is expected.
Implementors§
Source§impl Connection for Database
Implementation of Connection for the main Database struct.
impl Connection for Database
Implementation of Connection for the main Database struct.
Uses the internal connection pool to execute queries.
Source§impl<'a> Connection for Transaction<'a>
Implementation of Connection for a Transaction.
impl<'a> Connection for Transaction<'a>
Implementation of Connection for a Transaction.
Allows the QueryBuilder to use a transaction for executing queries.
Supports generic borrow lifetimes to allow multiple operations within
the same transaction scope.