pub struct PostgresConnectionManager<T> { /* private fields */ }
Expand description
An r2d2::ManageConnection
for postgres::Client
s.
§Example
use std::thread;
use r2d2_postgres::{postgres::NoTls, PostgresConnectionManager};
fn main() {
let manager = PostgresConnectionManager::new(
"host=localhost user=postgres".parse().unwrap(),
NoTls,
);
let pool = r2d2::Pool::new(manager).unwrap();
for i in 0..10i32 {
let pool = pool.clone();
thread::spawn(move || {
let mut client = pool.get().unwrap();
client.execute("INSERT INTO foo (bar) VALUES ($1)", &[&i]).unwrap();
});
}
}
Implementations§
Source§impl<T> PostgresConnectionManager<T>where
T: MakeTlsConnect<Socket> + Clone + 'static + Sync + Send,
T::TlsConnect: Send,
T::Stream: Send,
<T::TlsConnect as TlsConnect<Socket>>::Future: Send,
impl<T> PostgresConnectionManager<T>where
T: MakeTlsConnect<Socket> + Clone + 'static + Sync + Send,
T::TlsConnect: Send,
T::Stream: Send,
<T::TlsConnect as TlsConnect<Socket>>::Future: Send,
Sourcepub fn new(config: Config, tls_connector: T) -> PostgresConnectionManager<T>
pub fn new(config: Config, tls_connector: T) -> PostgresConnectionManager<T>
Creates a new PostgresConnectionManager
.
Trait Implementations§
Source§impl<T: Debug> Debug for PostgresConnectionManager<T>
impl<T: Debug> Debug for PostgresConnectionManager<T>
Source§impl<T> ManageConnection for PostgresConnectionManager<T>where
T: MakeTlsConnect<Socket> + Clone + 'static + Sync + Send,
T::TlsConnect: Send,
T::Stream: Send,
<T::TlsConnect as TlsConnect<Socket>>::Future: Send,
impl<T> ManageConnection for PostgresConnectionManager<T>where
T: MakeTlsConnect<Socket> + Clone + 'static + Sync + Send,
T::TlsConnect: Send,
T::Stream: Send,
<T::TlsConnect as TlsConnect<Socket>>::Future: Send,
Auto Trait Implementations§
impl<T> Freeze for PostgresConnectionManager<T>where
T: Freeze,
impl<T> !RefUnwindSafe for PostgresConnectionManager<T>
impl<T> Send for PostgresConnectionManager<T>where
T: Send,
impl<T> Sync for PostgresConnectionManager<T>where
T: Sync,
impl<T> Unpin for PostgresConnectionManager<T>where
T: Unpin,
impl<T> !UnwindSafe for PostgresConnectionManager<T>
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