Trait Executor

Source
pub trait Executor<'c>:
    Sized
    + Send
    + Debug {
    type Database: Database;

    // Required methods
    fn fetch_many<'e, 'q, E>(
        self,
        query: E,
    ) -> Pin<Box<dyn Stream<Item = Result<Either<<Self::Database as Database>::QueryResult, <Self::Database as Database>::Row>, Error>> + Send + 'e>>
       where 'q: 'e,
             'c: 'e,
             E: 'q + Execute<'q, Self::Database>;
    fn fetch_optional<'e, 'q, E>(
        self,
        query: E,
    ) -> Pin<Box<dyn Future<Output = Result<Option<<Self::Database as Database>::Row>, Error>> + Send + 'e>>
       where 'q: 'e,
             'c: 'e,
             E: 'q + Execute<'q, Self::Database>;
    fn prepare_with<'e, 'q>(
        self,
        sql: &'q str,
        parameters: &'e [<Self::Database as Database>::TypeInfo],
    ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as HasStatement<'q>>::Statement, Error>> + Send + 'e>>
       where 'q: 'e,
             'c: 'e;

    // Provided methods
    fn execute<'e, 'q, E>(
        self,
        query: E,
    ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
       where 'q: 'e,
             'c: 'e,
             E: 'q + Execute<'q, Self::Database> { ... }
    fn execute_many<'e, 'q, E>(
        self,
        query: E,
    ) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
       where 'q: 'e,
             'c: 'e,
             E: 'q + Execute<'q, Self::Database> { ... }
    fn fetch<'e, 'q, E>(
        self,
        query: E,
    ) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Row, Error>> + Send + 'e>>
       where 'q: 'e,
             'c: 'e,
             E: 'q + Execute<'q, Self::Database> { ... }
    fn fetch_all<'e, 'q, E>(
        self,
        query: E,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<<Self::Database as Database>::Row>, Error>> + Send + 'e>>
       where 'q: 'e,
             'c: 'e,
             E: 'q + Execute<'q, Self::Database> { ... }
    fn fetch_one<'e, 'q, E>(
        self,
        query: E,
    ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Row, Error>> + Send + 'e>>
       where 'q: 'e,
             'c: 'e,
             E: 'q + Execute<'q, Self::Database> { ... }
    fn prepare<'e, 'q>(
        self,
        query: &'q str,
    ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as HasStatement<'q>>::Statement, Error>> + Send + 'e>>
       where 'q: 'e,
             'c: 'e { ... }
}
Expand description

A type that contains or can provide a database connection to use for executing queries against the database.

No guarantees are provided that successive queries run on the same physical database connection.

A Connection is an Executor that guarantees that successive queries are ran on the same physical database connection.

Implemented for the following:

Required Associated Typesยง

Required Methodsยง

Source

fn fetch_many<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Stream<Item = Result<Either<<Self::Database as Database>::QueryResult, <Self::Database as Database>::Row>, Error>> + Send + 'e>>
where 'q: 'e, 'c: 'e, E: 'q + Execute<'q, Self::Database>,

Execute multiple queries and return the generated results as a stream from each query, in a stream.

Source

fn fetch_optional<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Future<Output = Result<Option<<Self::Database as Database>::Row>, Error>> + Send + 'e>>
where 'q: 'e, 'c: 'e, E: 'q + Execute<'q, Self::Database>,

Execute the query and returns at most one row.

Source

fn prepare_with<'e, 'q>( self, sql: &'q str, parameters: &'e [<Self::Database as Database>::TypeInfo], ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as HasStatement<'q>>::Statement, Error>> + Send + 'e>>
where 'q: 'e, 'c: 'e,

Prepare the SQL query, with parameter type information, to inspect the type information about its parameters and results.

Only some database drivers (PostgreSQL, MSSQL) can take advantage of this extra information to influence parameter type inference.

Provided Methodsยง

Source

fn execute<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
where 'q: 'e, 'c: 'e, E: 'q + Execute<'q, Self::Database>,

Execute the query and return the total number of rows affected.

Source

fn execute_many<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
where 'q: 'e, 'c: 'e, E: 'q + Execute<'q, Self::Database>,

Execute multiple queries and return the rows affected from each query, in a stream.

Source

fn fetch<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Row, Error>> + Send + 'e>>
where 'q: 'e, 'c: 'e, E: 'q + Execute<'q, Self::Database>,

Execute the query and return the generated results as a stream.

Source

fn fetch_all<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Future<Output = Result<Vec<<Self::Database as Database>::Row>, Error>> + Send + 'e>>
where 'q: 'e, 'c: 'e, E: 'q + Execute<'q, Self::Database>,

Execute the query and return all the generated results, collected into a Vec.

Source

fn fetch_one<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::Row, Error>> + Send + 'e>>
where 'q: 'e, 'c: 'e, E: 'q + Execute<'q, Self::Database>,

Execute the query and returns exactly one row.

Source

fn prepare<'e, 'q>( self, query: &'q str, ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as HasStatement<'q>>::Statement, Error>> + Send + 'e>>
where 'q: 'e, 'c: 'e,

Prepare the SQL query to inspect the type information of its parameters and results.

Be advised that when using the query, query_as, or query_scalar functions, the query is transparently prepared and executed.

This explicit API is provided to allow access to the statement metadata available after it prepared but before the first row is returned.

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.

Implementorsยง

Sourceยง

impl<'c> Executor<'c> for &'c mut PoolConnection<Any>

Sourceยง

impl<'c> Executor<'c> for &'c mut PoolConnection<Mssql>

Sourceยง

impl<'c> Executor<'c> for &'c mut PoolConnection<MySql>

Sourceยง

impl<'c> Executor<'c> for &'c mut PoolConnection<Postgres>

Sourceยง

impl<'c> Executor<'c> for &'c mut PoolConnection<Sqlite>

Sourceยง

impl<'c> Executor<'c> for &'c mut PgListener

Sourceยง

impl<'c> Executor<'c> for &'c mut AnyConnection

Sourceยง

impl<'c> Executor<'c> for &'c mut MssqlConnection

Sourceยง

impl<'c> Executor<'c> for &'c mut MySqlConnection

Sourceยง

impl<'c> Executor<'c> for &'c mut PgConnection

Sourceยง

impl<'c> Executor<'c> for &'c mut SqliteConnection

Sourceยง

impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Any>

Sourceยง

impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Mssql>

Sourceยง

impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, MySql>

Sourceยง

impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Postgres>

Sourceยง

impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Sqlite>

Sourceยง

impl<'p, DB> Executor<'p> for &Pool<DB>
where DB: Database, &'c mut <DB as Database>::Connection: for<'c> Executor<'c, Database = DB>,