pub struct LazySql<F>{ /* private fields */ }Expand description
A lazily-generated SQL string that defers construction until needed.
This is useful when you may not need the SQL string (e.g., when caching is available, or when the query may be abandoned before execution).
§Example
use prax_query::sql::{LazySql, DatabaseType};
// Create a lazy SQL generator
let lazy = LazySql::new(|db_type| {
format!("SELECT * FROM users WHERE active = {}", db_type.placeholder(1))
});
// SQL is not generated until accessed
let sql = lazy.get(DatabaseType::PostgreSQL);
assert_eq!(sql, "SELECT * FROM users WHERE active = $1");Implementations§
Auto Trait Implementations§
impl<F> Freeze for LazySql<F>where
F: Freeze,
impl<F> RefUnwindSafe for LazySql<F>where
F: RefUnwindSafe,
impl<F> Send for LazySql<F>where
F: Send,
impl<F> Sync for LazySql<F>where
F: Sync,
impl<F> Unpin for LazySql<F>where
F: Unpin,
impl<F> UnwindSafe for LazySql<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more