pub trait Executor<'c>:
Send
+ Debug
+ Sized {
type Database: Database;
// Required methods
fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<<Self::Database as Database>::QueryResult, <Self::Database as Database>::Row>, Error>>
where E: Execute<'q, Self::Database> + 'q,
'c: 'e;
fn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<<Self::Database as Database>::Row>, Error>>
where E: Execute<'q, Self::Database> + 'q,
'c: 'e;
fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>
where 'c: 'e;
// Provided methods
fn execute<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
where E: Execute<'q, Self::Database> + 'q,
'c: 'e { ... }
fn execute_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
where E: Execute<'q, Self::Database> + 'q,
'c: 'e { ... }
fn fetch<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
where E: Execute<'q, Self::Database> + 'q,
'c: 'e { ... }
fn fetch_all<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
where E: Execute<'q, Self::Database> + 'q,
'c: 'e { ... }
fn fetch_one<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::Row, Error>>
where E: Execute<'q, Self::Database> + 'q,
'c: 'e { ... }
fn prepare<'e, 'q: 'e>(
self,
query: &'q str,
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>
where '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§
Sourcefn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<<Self::Database as Database>::QueryResult, <Self::Database as Database>::Row>, Error>>
fn fetch_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<Either<<Self::Database as Database>::QueryResult, <Self::Database as Database>::Row>, Error>>
Execute multiple queries and return the generated results as a stream from each query, in a stream.
Sourcefn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<<Self::Database as Database>::Row>, Error>>
fn fetch_optional<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Option<<Self::Database as Database>::Row>, Error>>
Execute the query and returns at most one row.
Sourcefn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
'c: 'e,
fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Self::Database as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
'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§
Sourcefn execute<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute the query and return the total number of rows affected.
Sourcefn execute_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
fn execute_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
Execute multiple queries and return the rows affected from each query, in a stream.
Sourcefn fetch<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
fn fetch<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
Execute the query and return the generated results as a stream.
Sourcefn fetch_all<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
fn fetch_all<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
Execute the query and return all the generated results, collected into a Vec
.
Sourcefn fetch_one<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::Row, Error>>
fn fetch_one<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<<Self::Database as Database>::Row, Error>>
Execute the query and returns exactly one row.
Sourcefn prepare<'e, 'q: 'e>(
self,
query: &'q str,
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
'c: 'e,
fn prepare<'e, 'q: 'e>(
self,
query: &'q str,
) -> BoxFuture<'e, Result<<Self::Database as HasStatement<'q>>::Statement, Error>>where
'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 MssqlConnection
Available on crate feature mssql
only.
impl<'c> Executor<'c> for &'c mut MssqlConnection
mssql
only.Source§impl<'c> Executor<'c> for &'c mut MySqlConnection
Available on crate feature mysql
only.
impl<'c> Executor<'c> for &'c mut MySqlConnection
mysql
only.Source§impl<'c> Executor<'c> for &'c mut PoolConnection<Mssql>
Available on crate feature mssql
only.
impl<'c> Executor<'c> for &'c mut PoolConnection<Mssql>
mssql
only.Source§impl<'c> Executor<'c> for &'c mut PoolConnection<MySql>
Available on crate feature mysql
only.
impl<'c> Executor<'c> for &'c mut PoolConnection<MySql>
mysql
only.Source§impl<'c> Executor<'c> for &'c mut PoolConnection<Postgres>
Available on crate feature postgres
only.
impl<'c> Executor<'c> for &'c mut PoolConnection<Postgres>
postgres
only.Source§impl<'c> Executor<'c> for &'c mut PoolConnection<Sqlite>
Available on crate feature sqlite
only.
impl<'c> Executor<'c> for &'c mut PoolConnection<Sqlite>
sqlite
only.Source§impl<'c> Executor<'c> for &'c mut PgConnection
Available on crate feature postgres
only.
impl<'c> Executor<'c> for &'c mut PgConnection
postgres
only.Source§impl<'c> Executor<'c> for &'c mut PgListener
Available on crate feature postgres
only.
impl<'c> Executor<'c> for &'c mut PgListener
postgres
only.Source§impl<'c> Executor<'c> for &'c mut SqliteConnection
Available on crate feature sqlite
only.
impl<'c> Executor<'c> for &'c mut SqliteConnection
sqlite
only.Source§impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Mssql>
Available on crate feature mssql
only.
impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Mssql>
mssql
only.Source§impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, MySql>
Available on crate feature mysql
only.
impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, MySql>
mysql
only.Source§impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Postgres>
Available on crate feature postgres
only.
impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Postgres>
postgres
only.Source§impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Sqlite>
Available on crate feature sqlite
only.
impl<'c, 't> Executor<'t> for &'t mut Transaction<'c, Sqlite>
sqlite
only.