pub trait Executor {
type Rows<'a>: RowStream + 'a
where Self: 'a;
type Statement<'a>: PreparedStatement<Rows<'a> = Self::Rows<'a>> + 'a
where Self: 'a;
// Required methods
fn driver(&self) -> Driver;
fn query(
&mut self,
sql: &str,
) -> impl Future<Output = Result<Self::Rows<'_>>> + Send;
fn query_prepared_source<P>(
&mut self,
sql: &str,
params: &P,
) -> impl Future<Output = Result<Self::Rows<'_>>> + Send
where P: ParamSource + Sync + ?Sized;
fn prepare(
&mut self,
sql: &str,
) -> impl Future<Output = Result<Self::Statement<'_>>> + Send;
}Expand description
Something that can run SQL.
This is the trait behind query and prepare. [Connection], [Pool],
crate::PoolTransaction, crate::PooledConnection,
crate::PooledTransaction, and crate::Transaction all implement it.
Use this trait when you want generic code that can work with either a plain connection, a pool, or a transaction.
Rows<'a> is the stream type returned while the executor is borrowed for
'a. Statement<'a> is the prepared statement type returned from
Self::prepare.
Required Associated Types§
Sourcetype Statement<'a>: PreparedStatement<Rows<'a> = Self::Rows<'a>> + 'a
where
Self: 'a
type Statement<'a>: PreparedStatement<Rows<'a> = Self::Rows<'a>> + 'a where Self: 'a
Prepared statement returned by this executor.
Required Methods§
Sourcefn query(
&mut self,
sql: &str,
) -> impl Future<Output = Result<Self::Rows<'_>>> + Send
fn query( &mut self, sql: &str, ) -> impl Future<Output = Result<Self::Rows<'_>>> + Send
Runs SQL without explicit bound parameters.
For SQL with parameters, most code should use query or
Self::prepare instead of calling Self::query_prepared_source
directly.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".