[][src]Crate r2d2_mongodb

r2d2-mongodb

A MongoDB adaptor for r2d2 connection pool.

Example

extern crate r2d2;
extern crate r2d2_mongodb;

use r2d2::Pool;
use r2d2_mongodb::{ConnectionOptions, MongodbConnectionManager, VerifyPeer};

fn main () {
    let manager = MongodbConnectionManager::new(
        ConnectionOptions::builder()
            .with_host("localhost", 27017)
         // .with_ssl(
         //     Some("path/to/ca.crt"),
         //     "path/to/client.crt",
         //     "path/to/client.key",
         //     VerifyPeer::Yes
         // )
         // .with_unauthenticated_ssl(
         //     Some("path/to/ca.crt"),
         //     VerifyPeer::No
         // )
            .with_db("mydb")
            .with_auth("root", "password")
            .build()
    );

    // let pool = Pool::builder()
    //     .max_size(16)
    //     .build(manager)
    //     .unwrap();

    // ...
}

Re-exports

pub extern crate mongodb;
pub extern crate r2d2;

Structs

Auth
ConnectionOptions

Options with which the connections to MongoDB will be created

ConnectionOptionsBuilder

Builder for ConnectionOptions

Host
MongodbConnectionManager

Struct for managing a pool of MongoDB connections

SSLCert
SSLConfig

Enums

VerifyPeer

Whether or not to verify that the server's certificate is trusted