I have the following code:
use std::env;
use diesel_async::AsyncPgConnection;
use env_convert::get_default_env_var;
use diesel_async::pooled_connection::AsyncDieselConnectionManager;
use diesel_async::pooled_connection::deadpool::{Pool,BuildError};
async fn get_pool() -> Result<Pool<AsyncDieselConnectionManager<AsyncPgConnection>>, BuildError> {
let mex_connections: Result<usize,_> = get_default_env_var("MAX_DB_CONNECTIONS", "5").into();
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let config = AsyncDieselConnectionManager::<AsyncPgConnection>::new(db_url);
let pool = Pool::builder(config).build()?;
Ok(pool)
}
I am getting this error:
error[E0277]: the trait bound `AsyncDieselConnectionManager<AsyncPgConnection>: PoolableConnection` is not satisfied
--> src/db_pool.rs:11:16
|
11 | let pool = Pool::builder(config).build()?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PoolableConnection` is not implemented for `AsyncDieselConnectionManager<AsyncPgConnection>`
|
= help: the trait `PoolableConnection` is implemented for `AsyncPgConnection`
= note: required for `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>` to implement `deadpool::managed::Manager`
note: required by a bound in `deadpool::managed::Pool`
--> /home/disguys/.asdf/installs/rust/1.70.0/registry/src/index.crates.io-6f17d22bba15001f/deadpool-0.9.5/src/managed/mod.rs:264:20
|
264 | pub struct Pool<M: Manager, W: From<Object<M>> = Object<M>> {
| ^^^^^^^ required by this bound in `Pool`
I pulled this almost straight from the docs for diesel-async so I'm a bit confused as to why I am getting this error, and I am not sure how to fix it.