pub trait Executor {
// Required methods
fn execute_raw(
&self,
sql: &str,
params: Vec<Value>,
) -> impl Future<Output = Result<u64, FlozError>> + Send;
fn fetch_all<T>(
&self,
sql: &str,
params: Vec<Value>,
) -> impl Future<Output = Result<Vec<T>, FlozError>> + Send
where T: Send + Unpin + FlozRowBound;
fn fetch_one<T>(
&self,
sql: &str,
params: Vec<Value>,
) -> impl Future<Output = Result<T, FlozError>> + Send
where T: Send + Unpin + FlozRowBound;
fn fetch_optional<T>(
&self,
sql: &str,
params: Vec<Value>,
) -> impl Future<Output = Result<Option<T>, FlozError>> + Send
where T: Send + Unpin + FlozRowBound;
}Expand description
The core database execution trait.
All floz DAO and DSL methods accept &impl Executor, allowing
seamless switching between connection pools, transactions, and mocks.
ⓘ
// Both work:
let users = User::all(&db).await?;
let users = User::all(&tx).await?;Required Methods§
Sourcefn execute_raw(
&self,
sql: &str,
params: Vec<Value>,
) -> impl Future<Output = Result<u64, FlozError>> + Send
fn execute_raw( &self, sql: &str, params: Vec<Value>, ) -> impl Future<Output = Result<u64, FlozError>> + Send
Execute a raw SQL statement, returning the number of affected rows.
Sourcefn fetch_all<T>(
&self,
sql: &str,
params: Vec<Value>,
) -> impl Future<Output = Result<Vec<T>, FlozError>> + Send
fn fetch_all<T>( &self, sql: &str, params: Vec<Value>, ) -> impl Future<Output = Result<Vec<T>, FlozError>> + Send
Fetch all matching rows.
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.