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§
Sourcetype ExecuteOutput
type ExecuteOutput
outcome of execute. used for single time database response: number of rows affected by execution for example.
Sourcetype QueryOutput
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§
Sourcefn execute(self, cli: &'c C) -> Self::ExecuteOutput
fn execute(self, cli: &'c C) -> Self::ExecuteOutput
define how a statement is executed with single time response
Sourcefn query(self, cli: &'c C) -> Self::QueryOutput
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.