Crate deadpool_diesel[][src]

Expand description

Deadpool for Diesel 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 diesel connections.

Features

FeatureDescriptionExtra dependenciesDefault
sqliteEnable sqlite feature in diesel cratediesel/sqliteno
postgresEnable postgres feature in diesel cratediesel/postgresno
mysqlEnable mysql feature in diesel cratediesel/mysqlno
rt_tokio_1Enable support for tokio cratedeadpool/rt_tokio_1yes
rt_async-std_1Enable support for async-std cratedeadpool/rt_async-std_1no
serdeEnable support for serde cratedeadpool/serdeno

Example

use deadpool_diesel::sqlite::{Runtime, Manager, Pool};
use diesel::{prelude::*, select, sql_types::Text};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let manager = Manager::new(":memory:", Runtime::Tokio1);
    let pool = Pool::builder(manager)
        .max_size(8)
        .build()
        .unwrap();
    let conn = pool.get().await?;
    let result = conn.interact(|conn| {
        let query = select("Hello world!".into_sql::<Text>());
        query.get_result::<String>(conn)
    }).await??;
    assert!(result == "Hello world!");
    Ok(())
}

License

Licensed under either of

at your option.

Modules

mysqlmysql

Type aliases for using deadpool-diesel with MySQL.

postgrespostgres

Type aliases for using deadpool-diesel with PostgreSQL.

sqlitesqlite

Type aliases for using deadpool-diesel with SQLite.

Structs

Statistics regarding an object returned by the pool

Generic object and connection pool.

Pool configuration.

The current pool status.

This guard is returned when calling SyncWrapper::lock or SyncWrapper::try_lock. This is basicly just a wrapper around a MutexGuard but hides some implementation details.

Timeouts when getting Objects from a Pool.

Enums

Possible errors returned when managing Connections.

Possible errors returned when SyncWrapper::interact() fails.

Enumeration for picking a runtime implementation.

Type Definitions

Connection which is returned by the Pool.

Type alias for using deadpool::managed::PoolError with diesel.