Make PooledPostgresConnection use Deref
This commit is contained in:
parent
f35ca8a23e
commit
74e2fb0276
51
src/pool.rs
51
src/pool.rs
@ -2,17 +2,8 @@
|
|||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use {PostgresNotifications,
|
use {PostgresConnectParams, IntoConnectParams, PostgresConnection, SslMode};
|
||||||
PostgresConnectParams,
|
|
||||||
IntoConnectParams,
|
|
||||||
PostgresResult,
|
|
||||||
PostgresCancelData,
|
|
||||||
PostgresConnection,
|
|
||||||
PostgresStatement,
|
|
||||||
PostgresTransaction,
|
|
||||||
SslMode};
|
|
||||||
use error::PostgresConnectError;
|
use error::PostgresConnectError;
|
||||||
use types::ToSql;
|
|
||||||
|
|
||||||
struct InnerConnectionPool {
|
struct InnerConnectionPool {
|
||||||
params: PostgresConnectParams,
|
params: PostgresConnectParams,
|
||||||
@ -111,42 +102,8 @@ impl Drop for PooledPostgresConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PooledPostgresConnection {
|
impl Deref<PostgresConnection> for PooledPostgresConnection {
|
||||||
/// Like `PostgresConnection::prepare`.
|
fn deref<'a>(&'a self) -> &'a PostgresConnection {
|
||||||
pub fn prepare<'a>(&'a self, query: &str)
|
self.conn.get_ref()
|
||||||
-> PostgresResult<PostgresStatement<'a>> {
|
|
||||||
self.conn.get_ref().prepare(query)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Like `PostgresConnection::execute`.
|
|
||||||
pub fn execute(&self, query: &str, params: &[&ToSql])
|
|
||||||
-> PostgresResult<uint> {
|
|
||||||
self.conn.get_ref().execute(query, params)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Like `PostgresConnection::batch_execute`.
|
|
||||||
pub fn batch_execute(&self, query: &str) -> PostgresResult<()> {
|
|
||||||
self.conn.get_ref().batch_execute(query)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Like `PostgresConnection::transaction`.
|
|
||||||
pub fn transaction<'a>(&'a self)
|
|
||||||
-> PostgresResult<PostgresTransaction<'a>> {
|
|
||||||
self.conn.get_ref().transaction()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Like `PostgresConnection::notifications`.
|
|
||||||
pub fn notifications<'a>(&'a self) -> PostgresNotifications<'a> {
|
|
||||||
self.conn.get_ref().notifications()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Like `PostgresConnection::cancel_data`.
|
|
||||||
pub fn cancel_data(&self) -> PostgresCancelData {
|
|
||||||
self.conn.get_ref().cancel_data()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Like `PostgresConnection::is_desynchronized`.
|
|
||||||
pub fn is_desynchronized(&self) -> bool {
|
|
||||||
self.conn.get_ref().is_desynchronized()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user