Connection

Trait Connection 

Source
pub trait Connection {
    type Exec<'c>: Executor<'c, Database = Any>
       where Self: 'c;

    // Required method
    fn executor<'c>(&'c mut self) -> Self::Exec<'c>;
}
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§

Source

type Exec<'c>: Executor<'c, Database = Any> where Self: 'c

The type of the executor returned by this connection.

This uses GATs to bind the lifetime of the executor ('c) to the lifetime of the borrow of the connection (&'c mut self).

Required Methods§

Source

fn executor<'c>(&'c mut self) -> Self::Exec<'c>

Returns a mutable reference to the SQLx executor.

§Returns

An executor capable of running SQL queries (either a Pool or a Transaction).

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> Connection for &mut Transaction<'a, Any>

Implementation of Connection for a mutable reference to sqlx::Transaction.

Source§

type Exec<'c> = &'c mut AnyConnection where Self: 'c

Source§

fn executor<'c>(&'c mut self) -> Self::Exec<'c>

Implementors§

Source§

impl Connection for Database

Implementation of Connection for the main Database struct.

Uses the internal connection pool to execute queries.

Source§

type Exec<'c> = &'c Pool<Any>

Source§

impl<'a> Connection for &'a mut Database

Implementation of Connection for a mutable reference to Database.

Source§

type Exec<'c> = &'c Pool<Any> where Self: 'c

Source§

impl<'a> Connection for bottle_orm::transaction::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.

Source§

type Exec<'c> = &'c mut AnyConnection where Self: 'c

Source§

impl<'a, 'b> Connection for &'a mut bottle_orm::transaction::Transaction<'b>

Implementation of Connection for a mutable reference to Transaction.

Source§

type Exec<'c> = &'c mut AnyConnection where Self: 'c