pub struct PreparedStatement { /* private fields */ }Expand description
A prepared statement.
Prepared statements allow you to execute the same query multiple times with different parameters efficiently. The statement is prepared once on the server and can be executed many times with different parameter values.
For automatic cleanup, use [OwnedPreparedStatement] via [crate::Client::prepare].
§Example
let stmt = client.prepare("SELECT * FROM users WHERE id = $1")?;
let rows1 = client.execute(&stmt, params![42_i32])?;
let rows2 = client.execute(&stmt, params![100_i32])?;Implementations§
Source§impl PreparedStatement
impl PreparedStatement
Sourcepub fn param_types(&self) -> &[Oid]
pub fn param_types(&self) -> &[Oid]
Returns the parameter types.
Sourcepub fn param_count(&self) -> usize
pub fn param_count(&self) -> usize
Returns the number of parameters.
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Returns the number of result columns.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PreparedStatement
impl RefUnwindSafe for PreparedStatement
impl Send for PreparedStatement
impl Sync for PreparedStatement
impl Unpin for PreparedStatement
impl UnsafeUnpin 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request