Deadpool for R2D2 Managers Latest Version Unsafe forbidden Rust 1.54+

Deadpool is a dead simple async pool for connections and objects of any type.

This crate implements a deadpool manager for r2d2 managers.

Features

| Feature | Description | Extra dependencies | Default | | ------- | ----------- | ------------------ | ------- | | rt_tokio_1 | Enable support for tokio crate | deadpool/rt_tokio_1 | yes | | rt_async-std_1 | Enable support for async-std crate | deadpool/rt_async-std_1 | no | | serde | Enable support for serde crate | deadpool/serde | no |

Example

```rust use std::env;

use deadpoolr2d2::Runtime; use r2d2postgres::postgres::Error as PgError;

type PgManager = deadpoolr2d2::Manager< r2d2postgres::PostgresConnectionManager,

; type PgPool = deadpool_r2d2::Pool;

fn createpool(maxsize: usize) -> PgPool { let mut pgconfig = r2d2postgres::postgres::Config::new(); pgconfig.hostpath("/run/postgresql"); pgconfig.user(&env::var("USER").unwrap()); pgconfig.dbname("deadpool"); let r2d2manager = r2d2postgres::PostgresConnectionManager::new(pgconfig, r2d2postgres::postgres::NoTls); let manager = PgManager::new(r2d2manager, Runtime::Tokio1); let pool = PgPool::builder(manager) .maxsize(max_size) .build() .unwrap(); pool }

[tokio::main]

async fn main() -> Result<(), Box> { let pool = createpool(2); let client = pool.get().await.unwrap(); let answer: i32 = client .interact(|client| client.queryone("SELECT 42", &[]).map(|row| row.get(0))) .await??; assert_eq!(answer, 42); Ok(()) } ```

License

Licensed under either of

at your option.