pub trait Executor: Send + Sized {
type Driver: Driver;
// Required methods
fn prepare(
&mut self,
query: String,
) -> impl Future<Output = Result<Query<Self::Driver>>> + Send;
fn run<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Stream<Item = Result<QueryResult>> + Send;
// Provided methods
fn accepts_multiple_statements(&self) -> bool { ... }
fn driver(&self) -> Self::Driver
where Self: Sized { ... }
fn fetch<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Stream<Item = Result<RowLabeled>> + Send { ... }
fn execute<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Future<Output = Result<RowsAffected>> + Send { ... }
fn append<'a, E, It>(
&mut self,
entities: It,
) -> impl Future<Output = Result<RowsAffected>> + Send
where E: Entity + 'a,
It: IntoIterator<Item = &'a E> + Send,
<It as IntoIterator>::IntoIter: Send { ... }
}Expand description
Async query executor bound to a concrete Driver.
Responsibilities:
- Translate high-level operations into driver queries
- Stream results without buffering the entire result set (if possible)
- Provide ergonomic helpers for common patterns
Implementors typically wrap a connection or pooled handle.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn accepts_multiple_statements(&self) -> bool
fn accepts_multiple_statements(&self) -> bool
Returns true if the executor accepts multiple SQL statements in a single
request (e.g. CREATE; INSERT; SELECT). Defaults to true.
Sourcefn driver(&self) -> Self::Driverwhere
Self: Sized,
fn driver(&self) -> Self::Driverwhere
Self: Sized,
Driver instance.
Default implementation returns Default::default() for the associated
Driver. Executors that carry per-connection or pooled driver state
should override this method to return the appropriate driver instance.
Sourcefn fetch<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Stream<Item = Result<RowLabeled>> + Send
fn fetch<'s>( &'s mut self, query: impl AsQuery<Self::Driver> + 's, ) -> impl Stream<Item = Result<RowLabeled>> + Send
Stream only labeled rows (filters non-row results).
Sourcefn execute<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Future<Output = Result<RowsAffected>> + Send
fn execute<'s>( &'s mut self, query: impl AsQuery<Self::Driver> + 's, ) -> impl Future<Output = Result<RowsAffected>> + Send
Execute and aggregate affected rows.
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.