pub struct OwnedPreparedStatement { /* private fields */ }Expand description
Owned PostgreSQL prepared statement wrapper.
This is the owned counterpart to PreparedStatement that doesn’t have any lifetime
constraints. All data is owned by this struct, making it suitable for long-term storage,
caching, or passing across thread boundaries.
§Use Cases
- Caching: Store prepared statements in a cache for reuse
- Multi-threading: Pass prepared statements between threads (with tokio-postgres)
- Long-term storage: Keep prepared statements in application state
- Query reuse: Execute the same query with different parameters efficiently
§Examples
// Create a query and convert to SQL
let query = builder.select(user.name).from(user);
let sql = query.to_sql();
// In practice, the driver creates a PreparedStatement from the SQL
// let prepared = driver.prepare(sql)?;
// let owned: OwnedPreparedStatement = prepared.into_owned();
// Owned can be stored in a HashMap for reuse§Conversion
You can convert between borrowed and owned forms:
PreparedStatement::into_owned()→OwnedPreparedStatementOwnedPreparedStatement→PreparedStatement(viaFromtrait)
Trait Implementations§
Source§impl Clone for OwnedPreparedStatement
impl Clone for OwnedPreparedStatement
Source§fn clone(&self) -> OwnedPreparedStatement
fn clone(&self) -> OwnedPreparedStatement
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OwnedPreparedStatement
impl Debug for OwnedPreparedStatement
Source§impl Display for OwnedPreparedStatement
impl Display for OwnedPreparedStatement
Source§impl From<OwnedPreparedStatement> for PreparedStatement<'_>
impl From<OwnedPreparedStatement> for PreparedStatement<'_>
Source§fn from(value: OwnedPreparedStatement) -> Self
fn from(value: OwnedPreparedStatement) -> Self
Converts to this type from the input type.
Source§impl<'a> From<PreparedStatement<'a>> for OwnedPreparedStatement
impl<'a> From<PreparedStatement<'a>> for OwnedPreparedStatement
Source§fn from(value: PreparedStatement<'a>) -> Self
fn from(value: PreparedStatement<'a>) -> Self
Converts to this type from the input type.
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
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> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more