Skip to main content

Executor

Trait Executor 

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

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

Implemented by connections.

Required Associated Types§

Source

type Driver: Driver

Associated driver.

Required Methods§

Source

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

Actual implementation for prepare.

Source

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

Execute a query, streaming QueryResult (rows or affected counts).

Provided Methods§

Source

fn accepts_multiple_statements(&self) -> bool

Supports multiple statements per request.

Source

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

Get the driver instance.

Source

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

Prepare query.

Source

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

Execute a query yielding RowLabeled from the resulting stream (filtering out RowsAffected).

Source

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

Execute and aggregate affected rows counter.

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§