pub trait Statement: Send + Sealed {
type Output: Send;
// Required methods
fn execute<S: SqlExecutor>(
self,
connection: &S,
) -> Result<Self::Output, S::Error>;
fn execute_mut<S: SqlExecutorMut>(
self,
connection: &mut S,
) -> Result<Self::Output, S::Error>;
fn execute_async<S: SqlExecutorAsync>(
self,
connection: &mut S,
) -> impl Future<Output = Result<Self::Output, S::Error>> + Send;
// Provided methods
fn then<Q: Statement>(self, statement: Q) -> Then<Self, Q>
where Self: Sized { ... }
fn pipe<Q: StatementWithInput<Input = Self::Output> + Send>(
self,
statement: Q,
) -> Pipe<Self, Q>
where Self: Sized { ... }
fn spanned(self, span: Span) -> TracedStatement<Self>
where Self: Sized { ... }
fn spanned_in_current(self) -> TracedStatement<Self>
where Self: Sized { ... }
}
Expand description
Basic abstraction that defers the execution of a SQL statement in order to reduce the duplication of sync and async code. Basic composability and chaining are also included.
The Send
requirement is in theory not required for sync implementations, but this is not
intended to be used outside of the scope of this crate.
Required Associated Types§
Required Methods§
Sourcefn execute_mut<S: SqlExecutorMut>(
self,
connection: &mut S,
) -> Result<Self::Output, S::Error>
fn execute_mut<S: SqlExecutorMut>( self, connection: &mut S, ) -> Result<Self::Output, S::Error>
Sourcefn execute_async<S: SqlExecutorAsync>(
self,
connection: &mut S,
) -> impl Future<Output = Result<Self::Output, S::Error>> + Send
fn execute_async<S: SqlExecutorAsync>( self, connection: &mut S, ) -> impl Future<Output = Result<Self::Output, S::Error>> + Send
Provided Methods§
Sourcefn then<Q: Statement>(self, statement: Q) -> Then<Self, Q>where
Self: Sized,
fn then<Q: Statement>(self, statement: Q) -> Then<Self, Q>where
Self: Sized,
If this statement succeeds, then execute the next statement
.
Sourcefn pipe<Q: StatementWithInput<Input = Self::Output> + Send>(
self,
statement: Q,
) -> Pipe<Self, Q>where
Self: Sized,
fn pipe<Q: StatementWithInput<Input = Self::Output> + Send>(
self,
statement: Q,
) -> Pipe<Self, Q>where
Self: Sized,
if the current statement succeeds, then execute the next statement
with output of the
current Statement
.
Sourcefn spanned(self, span: Span) -> TracedStatement<Self>where
Self: Sized,
fn spanned(self, span: Span) -> TracedStatement<Self>where
Self: Sized,
Instrument the current statement with the given Span
Sourcefn spanned_in_current(self) -> TracedStatement<Self>where
Self: Sized,
fn spanned_in_current(self) -> TracedStatement<Self>where
Self: Sized,
Instrument the current statement with currently active Span
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.