Struct r2d2_postgres::PostgresConnectionManager [−][src]
pub struct PostgresConnectionManager<T> { /* fields omitted */ }
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
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,
Creates a new PostgresConnectionManager
.
Trait Implementations
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,
type Connection = Client
type Connection = Client
The connection type this manager deals with.
Determines if the connection is still connected to the database. Read more
Quickly determines if the connection is no longer usable. Read more