Executor

Trait Executor 

Source
pub trait Executor: Send + Sized {
    type Driver: Driver;

    // Required methods
    fn driver(&self) -> &Self::Driver;
    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 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§

Source

type Driver: Driver

Associated driver.

Required Methods§

Source

fn driver(&self) -> &Self::Driver

Driver instance.

Source

fn prepare( &mut self, query: String, ) -> impl Future<Output = Result<Query<Self::Driver>>> + Send

Prepare a query for later execution.

Source

fn run<'s>( &'s mut self, query: impl AsQuery<Self::Driver> + 's, ) -> impl Stream<Item = Result<QueryResult>> + Send

Run a query, streaming QueryResult items.

Provided Methods§

Source

fn accepts_multiple_statements(&self) -> bool

Source

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).

Source

fn execute<'s>( &'s mut self, query: impl AsQuery<Self::Driver> + 's, ) -> impl Future<Output = Result<RowsAffected>> + Send

Execute and aggregate affected rows.

Source

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,

Insert many entities efficiently.

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§