pub struct PooledConnection { /* private fields */ }Expand description
A connection managed by a pool.
This struct is thread-safe (Sync) because the return callback is protected by a Mutex.
Implementations§
Source§impl PooledConnection
impl PooledConnection
Sourcepub fn new<F>(connection: Arc<Connection>, on_return: F) -> Self
pub fn new<F>(connection: Arc<Connection>, on_return: F) -> Self
Create a new pooled connection.
Sourcepub fn connection(&self) -> &Connection
pub fn connection(&self) -> &Connection
Get a reference to the underlying connection.
Sourcepub fn inner(&self) -> &Connection
pub fn inner(&self) -> &Connection
Get the underlying connection (alias for connection()).
Sourcepub async fn query(&self, sql: &str) -> Result<QueryResult, ClientError>
pub async fn query(&self, sql: &str) -> Result<QueryResult, ClientError>
Execute a query.
Methods from Deref<Target = Connection>§
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if connected.
Sourcepub fn in_transaction(&self) -> bool
pub fn in_transaction(&self) -> bool
Check if in a transaction.
Sourcepub async fn query(&self, sql: &str) -> Result<QueryResult, ClientError>
pub async fn query(&self, sql: &str) -> Result<QueryResult, ClientError>
Execute a query.
Sourcepub async fn query_with_params(
&self,
sql: &str,
params: Vec<Value>,
) -> Result<QueryResult, ClientError>
pub async fn query_with_params( &self, sql: &str, params: Vec<Value>, ) -> Result<QueryResult, ClientError>
Execute a query with parameters.
Sourcepub async fn execute(&self, sql: &str) -> Result<u64, ClientError>
pub async fn execute(&self, sql: &str) -> Result<u64, ClientError>
Execute a statement (INSERT, UPDATE, DELETE).
Sourcepub async fn execute_with_params(
&self,
sql: &str,
params: Vec<Value>,
) -> Result<u64, ClientError>
pub async fn execute_with_params( &self, sql: &str, params: Vec<Value>, ) -> Result<u64, ClientError>
Execute a statement with parameters.
Sourcepub async fn begin_transaction(&self) -> Result<(), ClientError>
pub async fn begin_transaction(&self) -> Result<(), ClientError>
Begin a transaction.
Sourcepub async fn commit(&self) -> Result<(), ClientError>
pub async fn commit(&self) -> Result<(), ClientError>
Commit a transaction.
Sourcepub async fn rollback(&self) -> Result<(), ClientError>
pub async fn rollback(&self) -> Result<(), ClientError>
Rollback a transaction.
Sourcepub async fn ping(&self) -> Result<(), ClientError>
pub async fn ping(&self) -> Result<(), ClientError>
Ping the connection.
Sourcepub fn stats(&self) -> ConnectionStats
pub fn stats(&self) -> ConnectionStats
Get connection statistics.
Trait Implementations§
Source§impl Deref for PooledConnection
impl Deref for PooledConnection
Auto Trait Implementations§
impl !Freeze for PooledConnection
impl !RefUnwindSafe for PooledConnection
impl Send for PooledConnection
impl Sync for PooledConnection
impl Unpin for PooledConnection
impl UnsafeUnpin for PooledConnection
impl !UnwindSafe for PooledConnection
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