Struct r2d2_postgres::PostgresConnectionManager [] [src]

pub struct PostgresConnectionManager { /* fields omitted */ }

An r2d2::ManageConnection for postgres::Connections.

Example

extern crate r2d2;
extern crate r2d2_postgres;

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

fn main() {
    let manager = PostgresConnectionManager::new("postgres://postgres@localhost",
                                                 TlsMode::None).unwrap();
    let pool = r2d2::Pool::new(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();
        });
    }
}

Methods

impl PostgresConnectionManager
[src]

[src]

Creates a new PostgresConnectionManager.

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

Trait Implementations

impl Debug for PostgresConnectionManager
[src]

[src]

Formats the value using the given formatter.

impl ManageConnection for PostgresConnectionManager
[src]

The connection type this manager deals with.

The error type returned by Connections.

[src]

Attempts to create a new connection.

[src]

Determines if the connection is still connected to the database. Read more

[src]

Quickly determines if the connection is no longer usable. Read more