pub struct OwnedPreparedStatement { /* private fields */ }Expand description
A prepared statement that automatically closes itself when dropped.
This is the recommended way to use prepared statements. It holds a weak reference to the connection and automatically closes the statement when dropped.
§Example
// Statement automatically closes when it goes out of scope
{
let stmt = client.prepare("SELECT * FROM users WHERE id = $1")?;
let rows = client.execute(&stmt, params![42_i32])?;
} // Statement is automatically closed hereImplementations§
Source§impl OwnedPreparedStatement
impl OwnedPreparedStatement
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.
Sourcepub fn statement(&self) -> &PreparedStatement
pub fn statement(&self) -> &PreparedStatement
Returns a reference to the underlying PreparedStatement.
Sourcepub fn close(self) -> Result<()>
pub fn close(self) -> Result<()>
Explicitly closes the statement, returning any error.
This is called automatically when the OwnedPreparedStatement is
dropped, but errors are silently ignored in that case. Use this
method if you need to handle close errors.
§Errors
Propagates any error from close_statement — connection
mutex poisoning, server-side error during Close/Sync, or
wire I/O failure. Returns Ok(()) without contacting the server
when the connection has already been dropped.
Trait Implementations§
Source§impl Debug for OwnedPreparedStatement
impl Debug for OwnedPreparedStatement
Source§impl Drop for OwnedPreparedStatement
impl Drop for OwnedPreparedStatement
Auto Trait Implementations§
impl Freeze for OwnedPreparedStatement
impl RefUnwindSafe for OwnedPreparedStatement
impl Send for OwnedPreparedStatement
impl Sync for OwnedPreparedStatement
impl Unpin for OwnedPreparedStatement
impl UnsafeUnpin for OwnedPreparedStatement
impl UnwindSafe for OwnedPreparedStatement
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
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>
T in a tonic::Request