pub trait Executor: Sized + Send {
type Driver: Driver;
// Required methods
fn driver(&self) -> &Self::Driver;
fn prepare(
&mut self,
query: String,
) -> impl Future<Output = Result<Query<Self::Driver>, Error>> + Send;
fn run<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Stream<Item = Result<QueryResult, Error>> + Send;
// Provided methods
fn fetch<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Stream<Item = Result<RowLabeled, Error>> + Send + 's { ... }
fn execute<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Future<Output = Result<RowsAffected, Error>> + Send { ... }
fn append<'a, E, It>(
&mut self,
entities: It,
) -> impl Future<Output = Result<RowsAffected, Error>> + Send
where E: Entity + 'a,
It: IntoIterator<Item = &'a E> + 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§
Sourcefn prepare(
&mut self,
query: String,
) -> impl Future<Output = Result<Query<Self::Driver>, Error>> + Send
fn prepare( &mut self, query: String, ) -> impl Future<Output = Result<Query<Self::Driver>, Error>> + Send
Prepare a query (e.g. statement caching / parameter binding) returning a Query.
Await/Consume:
- Must be awaited; preparation may allocate resources on the driver.
Errors:
- Driver-specific preparation failures.
Sourcefn run<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Stream<Item = Result<QueryResult, Error>> + Send
fn run<'s>( &'s mut self, query: impl AsQuery<Self::Driver> + 's, ) -> impl Stream<Item = Result<QueryResult, Error>> + Send
Run an already prepared query, streaming heterogeneous QueryResult items.
Await/Consume:
- You must drive the returned stream to completion (or until you intentionally stop).
Stream Items:
QueryResult::Rowfor each produced row.QueryResult::Affectedfor write operations (may appear before/after rows depending on driver).
Errors:
- Emitted inline in the stream; consumers should use
TryStreamExt.
Provided Methods§
Sourcefn fetch<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Stream<Item = Result<RowLabeled, Error>> + Send + 's
fn fetch<'s>( &'s mut self, query: impl AsQuery<Self::Driver> + 's, ) -> impl Stream<Item = Result<RowLabeled, Error>> + Send + 's
Run a query and stream only labeled rows, filtering out non-row results.
Await/Consume:
- Consume the stream fully if you expect to release underlying resources cleanly.
Each error from run is forwarded; affected-count results are discarded.
Sourcefn execute<'s>(
&'s mut self,
query: impl AsQuery<Self::Driver> + 's,
) -> impl Future<Output = Result<RowsAffected, Error>> + Send
fn execute<'s>( &'s mut self, query: impl AsQuery<Self::Driver> + 's, ) -> impl Future<Output = Result<RowsAffected, Error>> + Send
Execute a query and return a single aggregated RowsAffected.
Await/Consume:
- Must be awaited; no side-effects are guaranteed until completion.
If a driver returns multiple QueryResult::Affected values, they are combined via FromIterator
(driver/module must provide the appropriate implementation).
Sourcefn append<'a, E, It>(
&mut self,
entities: It,
) -> impl Future<Output = Result<RowsAffected, Error>> + Send
fn append<'a, E, It>( &mut self, entities: It, ) -> impl Future<Output = Result<RowsAffected, Error>> + Send
Append entities to a table.
Await/Consume:
- Must be awaited; insertion may be deferred until polled.
Semantics:
- Uses driver append/ingest feature when supported.
- Falls back to plain INSERT statements via
sql_writer().write_insert(..., false)otherwise.
Returns:
- Total number of inserted 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.