Skip to main content

Executor

Trait Executor 

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

    // Required method
    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 prepare<'s>(
        &'s mut self,
        query: impl AsQuery<Self::Driver> + 's,
    ) -> impl Future<Output = Result<Query<Self::Driver>>> + Send { ... }
    fn do_prepare(
        &mut self,
        _sql: String,
    ) -> impl Future<Output = Result<Query<Self::Driver>>> + Send { ... }
    fn fetch<'s>(
        &'s mut self,
        query: impl AsQuery<Self::Driver> + 's,
    ) -> impl Stream<Item = Result<Row>> + 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 execution.

Implemented by connections.

Required Associated Types§

Source

type Driver: Driver

Associated driver.

Required Methods§

Source

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

Executes a query and streams the results (rows or affected counts).

Provided Methods§

Source

fn accepts_multiple_statements(&self) -> bool

Checks if the driver supports multiple SQL statements in a single request.

Source

fn driver(&self) -> Self::Driver
where Self: Sized,

Returns the driver instance associated with this executor.

Source

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

Prepares a query for execution, returning a handle to the prepared statement.

Source

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

Internal hook for implementing prepared statement support.

Source

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

Executes a query and streams the resulting rows, ignoring affected counts.

Source

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

Executes a query and returns the total number of 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,

Efficiently inserts a collection of entities bypassing regular SQL execution when supported by the driver.

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§