pub struct PreparedStatement { /* private fields */ }Expand description
A prepared statement for repeated execution.
Prepared statements are pre-compiled by the database, allowing efficient repeated execution with different parameter values. They also help prevent SQL injection since parameters are handled separately from the SQL text.
Implementations§
Source§impl PreparedStatement
impl PreparedStatement
Sourcepub fn new(id: u64, sql: String, param_count: usize) -> Self
pub fn new(id: u64, sql: String, param_count: usize) -> Self
Create a new prepared statement.
This is typically called by the driver, not by users directly.
Sourcepub fn with_columns(
id: u64,
sql: String,
param_count: usize,
columns: Vec<String>,
) -> Self
pub fn with_columns( id: u64, sql: String, param_count: usize, columns: Vec<String>, ) -> Self
Create a prepared statement with column information.
Sourcepub const fn param_count(&self) -> usize
pub const fn param_count(&self) -> usize
Get the expected number of parameters.
Sourcepub fn validate_params(&self, params: &[Value]) -> bool
pub fn validate_params(&self, params: &[Value]) -> bool
Check if the provided parameters match the expected count.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).