pub struct CachedStatement { /* private fields */ }Expand description
Cached Statement from PoolConnection
Can be used for the same purpose without the ability to cancel actively
It’s lifetime is managed by PoolConnection
Methods from Deref<Target = Statement>§
Sourcepub fn bind<P>(&self, params: P) -> StatementPreparedQuery<'_, P>where
P: AsParams,
pub fn bind<P>(&self, params: P) -> StatementPreparedQuery<'_, P>where
P: AsParams,
bind self to typed value parameters where they are encoded into a valid sql query in binary format
§Examples
// prepare a statement with typed parameters.
let stmt = Statement::named("SELECT * FROM users WHERE id = $1 AND age = $2", &[Type::INT4, Type::INT4])
.execute(&cli).await?;
// bind statement to typed value parameters and start query
let row_stream = stmt.bind([9527_i32, 18]).query(&cli).await?;Sourcepub fn bind_dyn<'p, 't>(
&self,
params: &'p [&'t (dyn ToSql + Sync)],
) -> StatementPreparedQuery<'_, impl ExactSizeIterator<Item = &'t (dyn ToSql + Sync)> + Clone + 'p>
pub fn bind_dyn<'p, 't>( &self, params: &'p [&'t (dyn ToSql + Sync)], ) -> StatementPreparedQuery<'_, impl ExactSizeIterator<Item = &'t (dyn ToSql + Sync)> + Clone + 'p>
Statement::bind for dynamic typed parameters
§Examples
// bind to a dynamic typed slice where items have it's own concrete type.
let bind = statement.bind_dyn(&[&9527i32, &"nobody"]);Sourcepub fn bind_none(&self) -> StatementPreparedQuery<'_, [bool; 0]>
pub fn bind_none(&self) -> StatementPreparedQuery<'_, [bool; 0]>
specialized binding api for zero sized parameters.
function the same as Statement::bind([])
Trait Implementations§
Source§impl Clone for CachedStatement
impl Clone for CachedStatement
Auto Trait Implementations§
impl Freeze for CachedStatement
impl RefUnwindSafe for CachedStatement
impl Send for CachedStatement
impl Sync for CachedStatement
impl Unpin for CachedStatement
impl UnwindSafe for CachedStatement
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