Trait Execute

Source
pub trait Execute<'c, C>
where Self: Sized,
{ type ExecuteOutput; type QueryOutput; // Required methods fn execute(self, cli: &'c C) -> Self::ExecuteOutput; fn query(self, cli: &'c C) -> Self::QueryOutput; }
Expand description

Defining how a query is executed. can be used for customizing encoding, executing and database data decoding.

For customized encoding please see Encode trait for detail. For customized decoding please see IntoResponse trait for detail.

when to use execute or query methods:

  • execute method is for use case where sql produce an outcome where it only happen once. usually in the form of preparing a statement or observing how many rows have been modified.
  • query method is for use case where sql produce repeated outcome where it can happen multiple times. usually in the form of visiting an iteration of database rows.

Required Associated Types§

Source

type ExecuteOutput

outcome of execute. used for single time database response: number of rows affected by execution for example.

Source

type QueryOutput

outcome of query. used for repeated database response: database rows for example

consider impl AsyncLendingIterator for async iterator of rows consider impl Iterator for iterator of rows

for type of statement where no repeated response will returning this type can point to Execute::ExecuteOutput and it’s encouraged to make query behave identical to execute

Required Methods§

Source

fn execute(self, cli: &'c C) -> Self::ExecuteOutput

define how a statement is executed with single time response

Source

fn query(self, cli: &'c C) -> Self::QueryOutput

define how a statement is queried with repeated response

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.

Implementations on Foreign Types§

Source§

impl<'c, C> Execute<'c, C> for &Path
where C: Query + Sync + 'c,

Source§

type ExecuteOutput = Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'c>>

Source§

type QueryOutput = Pin<Box<dyn Future<Output = Result<GenericRowStream<Vec<Column>, NoTyped>, Error>> + Send + 'c>>

Source§

fn execute(self, cli: &'c C) -> Self::ExecuteOutput

Source§

fn query(self, cli: &'c C) -> Self::QueryOutput

Source§

impl<'s, C> Execute<'_, C> for &'s str
where C: Query,

Source§

type ExecuteOutput = ResultFuture<RowAffected>

Source§

type QueryOutput = Ready<Result<GenericRowStream<Vec<Column>, NoTyped>, Error>>

Source§

fn execute(self, cli: &C) -> Self::ExecuteOutput

Source§

fn query(self, cli: &C) -> Self::QueryOutput

Implementors§

Source§

impl<'c, C> Execute<'c, C> for StatementNamed<'_>
where C: Prepare + 'c,

Source§

type ExecuteOutput = ResultFuture<IntoGuarded<'c, Pin<Box<dyn Future<Output = Result<Statement, Error>> + Send + 'c>>, C>>

Source§

type QueryOutput = <StatementNamed<'_> as Execute<'c, C>>::ExecuteOutput

Source§

impl<'c, C, P> Execute<'c, C> for StatementUnnamedBind<'_, P>
where C: Prepare + 'c, P: AsParams,

Source§

type ExecuteOutput = ResultFuture<RowAffected>

Source§

type QueryOutput = Ready<Result<RowStreamGuarded<'c, C>, Error>>

Source§

impl<'p, C, B, const SYNC_MODE: bool> Execute<'_, C> for Pipeline<'p, B, SYNC_MODE>
where C: Query, B: DerefMut<Target = BytesMut>,

Source§

impl<'s, C> Execute<'_, C> for &'s Statement
where C: Query,

Source§

type ExecuteOutput = ResultFuture<RowAffected>

Source§

type QueryOutput = Ready<Result<GenericRowStream<&'s [Column], Typed>, Error>>

Source§

impl<'s, C, P> Execute<'_, C> for StatementQuery<'s, P>
where C: Query, P: AsParams,

Source§

type ExecuteOutput = ResultFuture<RowAffected>

Source§

type QueryOutput = Ready<Result<GenericRowStream<&'s [Column], Typed>, Error>>