pub struct PreparedStatement { /* private fields */ }Expand description
A prepared statement handle with pre-computed statement name. This eliminates per-query hash computation and HashMap lookup. Create once, execute many times.
§Example
ⓘ
// Prepare once (compute hash + register with PostgreSQL)
let stmt = conn.prepare("SELECT id, name FROM users WHERE id = $1").await?;
// Execute many times (no hash, no lookup!)
for id in 1..1000 {
conn.execute_prepared(&stmt, &[Some(id.to_string().into_bytes())]).await?;
}Implementations§
Source§impl PreparedStatement
impl PreparedStatement
Sourcepub fn from_sql_bytes(sql_bytes: &[u8]) -> Self
pub fn from_sql_bytes(sql_bytes: &[u8]) -> Self
Create a new prepared statement handle from SQL bytes. This hashes the SQL bytes directly without String allocation.
Trait Implementations§
Source§impl Clone for PreparedStatement
impl Clone for PreparedStatement
Source§fn clone(&self) -> PreparedStatement
fn clone(&self) -> PreparedStatement
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PreparedStatement
impl RefUnwindSafe for PreparedStatement
impl Send for PreparedStatement
impl Sync for PreparedStatement
impl Unpin for PreparedStatement
impl UnwindSafe for PreparedStatement
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