easy_sql/traits/
easy_executor.rs1use easy_macros::always_context;
2
3use crate::Driver;
4
5use super::DriverConnection;
6
7#[always_context]
8pub trait EasyExecutor<D: Driver> {
15 type InternalExecutor<'b>: sqlx::Executor<'b, Database = D::InternalDriver>
16 where
17 Self: 'b;
18 type IntoInternalExecutor<'b>: sqlx::Executor<'b, Database = D::InternalDriver>
19 where
20 Self: 'b;
21
22 async fn query_setup<O: SetupSql<D> + Send + Sync>(
23 &mut self,
24 sql: O,
25 ) -> anyhow::Result<O::Output>
26 where
27 DriverConnection<D>: Send + Sync;
28
29 fn executor<'a>(&'a mut self) -> Self::InternalExecutor<'a>;
30
31 fn into_executor<'a>(self) -> Self::IntoInternalExecutor<'a>
32 where
33 Self: 'a;
34}
35
36#[always_context]
37pub trait SetupSql<D: Driver> {
39 type Output;
40
41 async fn query(self, exec: &mut impl EasyExecutor<D>) -> anyhow::Result<Self::Output>;
42}