Struct r2d2_postgres::PostgresConnectionManager [] [src]

pub struct PostgresConnectionManager {
    // some fields omitted

An r2d2::ManageConnection for postgres::Connections.


extern crate r2d2;
extern crate r2d2_postgres;
extern crate postgres;

use std::thread;
use r2d2_postgres::{SslMode, PostgresConnectionManager};

fn main() {
    let config = r2d2::Config::default();
    let manager = PostgresConnectionManager::new("postgres://[email protected]",
    let pool = r2d2::Pool::new(config, manager).unwrap();

    for i in 0..10i32 {
        let pool = pool.clone();
        thread::spawn(move || {
            let conn = pool.get().unwrap();
            conn.execute("INSERT INTO foo (bar) VALUES ($1)", &[&i]).unwrap();


impl PostgresConnectionManager

fn new<T: IntoConnectParams>(params: T, ssl_mode: SslMode) -> Result<PostgresConnectionManager, ConnectError>

Creates a new PostgresConnectionManager.

See postgres::Connection::connect for a description of the parameter types.

Trait Implementations

impl ManageConnection for PostgresConnectionManager

type Connection = Connection

type Error = Error

fn connect(&self) -> Result<Connection, Error>

fn is_valid(&self, conn: &mut Connection) -> Result<(), Error>

fn has_broken(&self, conn: &mut Connection) -> bool

Derived Implementations

impl Debug for PostgresConnectionManager

fn fmt(&self, __arg_0: &mut Formatter) -> Result