You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cant even return pool connection from a function
use diesel_async::pooled_connection::AsyncDieselConnectionManager;
use diesel_async::pooled_connection::deadpool::Pool;
use diesel_async::RunQueryDsl;
use diesel_async::AsyncPgConnection;
fn create_db_pool() -> Pool<AsyncDieselConnectionManager<AsyncPgConnection>> {
dotenv().ok();
let config = AsyncDieselConnectionManager::<diesel_async::AsyncPgConnection>::new(std::env::var("DATABASE_URL")?);
let pool = Pool::builder(config)
.max_size(20)
.build()?;
pool
}
But got
error[E0277]: the trait bound `AsyncDieselConnectionManager<AsyncPgConnection>: PoolableConnection` is not satisfied
--> lib/src/lib.rs:22:24
|
22 | fn create_db_pool() -> Pool<AsyncDieselConnectionManager<AsyncPgConnection>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PoolableConnection` is not implemented for `AsyncDieselConnectionManager<AsyncPgConnection>`, which is required by `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>: deadpool::managed::Manager`
|
= 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/eugenebos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deadpool-0.12.1/src/managed/mod.rs:249:20
|
249 | pub struct Pool<M: Manager, W: From<Object<M>> = Object<M>> {
| ^^^^^^^ required by this bound in `Pool`
error[E0277]: the trait bound `AsyncDieselConnectionManager<AsyncPgConnection>: DerefMut` is not satisfied
--> lib/src/lib.rs:22:24
|
22 | fn create_db_pool() -> Pool<AsyncDieselConnectionManager<AsyncPgConnection>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `DerefMut` is not implemented for `AsyncDieselConnectionManager<AsyncPgConnection>`, which is required by `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>: deadpool::managed::Manager`
|
= help: the trait `deadpool::managed::Manager` is implemented for `AsyncDieselConnectionManager<C>`
= note: required for `AsyncDieselConnectionManager<AsyncPgConnection>` to implement `AsyncConnection`
= note: required for `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>` to implement `deadpool::managed::Manager`
note: required by a bound in `deadpool::managed::Pool`
--> /home/eugenebos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deadpool-0.12.1/src/managed/mod.rs:249:20
|
249 | pub struct Pool<M: Manager, W: From<Object<M>> = Object<M>> {
| ^^^^^^^ required by this bound in `Pool`
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> lib/src/lib.rs:31:113
|
22 | fn create_db_pool() -> Pool<AsyncDieselConnectionManager<AsyncPgConnection>> {
| ---------------------------------------------------------------------------- this function should return `Result` or `Option` to accept `?`
...
31 | let config = AsyncDieselConnectionManager::<diesel_async::AsyncPgConnection>::new(std::env::var("DATABASE_URL")?);
| ^ cannot use the `?` operator in a function that returns `deadpool::managed::Pool<AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>>`
|
= help: the trait `FromResidual<Result<Infallible, VarError>>` is not implemented for `deadpool::managed::Pool<AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>>`
error[E0277]: the trait bound `AsyncDieselConnectionManager<AsyncPgConnection>: PoolableConnection` is not satisfied
--> lib/src/lib.rs:31:84
|
31 | let config = AsyncDieselConnectionManager::<diesel_async::AsyncPgConnection>::new(std::env::var("DATABASE_URL")?);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PoolableConnection` is not implemented for `AsyncDieselConnectionManager<AsyncPgConnection>`, which is required by `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>: deadpool::managed::Manager`
|
= 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/eugenebos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deadpool-0.12.1/src/managed/mod.rs:249:20
|
249 | pub struct Pool<M: Manager, W: From<Object<M>> = Object<M>> {
| ^^^^^^^ required by this bound in `Pool`
error[E0277]: the trait bound `AsyncDieselConnectionManager<AsyncPgConnection>: DerefMut` is not satisfied
--> lib/src/lib.rs:31:84
|
31 | let config = AsyncDieselConnectionManager::<diesel_async::AsyncPgConnection>::new(std::env::var("DATABASE_URL")?);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `DerefMut` is not implemented for `AsyncDieselConnectionManager<AsyncPgConnection>`, which is required by `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>: deadpool::managed::Manager`
|
= help: the trait `deadpool::managed::Manager` is implemented for `AsyncDieselConnectionManager<C>`
= note: required for `AsyncDieselConnectionManager<AsyncPgConnection>` to implement `AsyncConnection`
= note: required for `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>` to implement `deadpool::managed::Manager`
note: required by a bound in `deadpool::managed::Pool`
--> /home/eugenebos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deadpool-0.12.1/src/managed/mod.rs:249:20
|
249 | pub struct Pool<M: Manager, W: From<Object<M>> = Object<M>> {
| ^^^^^^^ required by this bound in `Pool`
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> lib/src/lib.rs:34:11
|
22 | fn create_db_pool() -> Pool<AsyncDieselConnectionManager<AsyncPgConnection>> {
| ---------------------------------------------------------------------------- this function should return `Result` or `Option` to accept `?`
...
34 | .build()?;
| ^ cannot use the `?` operator in a function that returns `deadpool::managed::Pool<AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>>`
|
= help: the trait `FromResidual<Result<Infallible, deadpool::managed::builder::BuildError>>` is not implemented for `deadpool::managed::Pool<AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>>`
error[E0277]: the trait bound `AsyncDieselConnectionManager<AsyncPgConnection>: PoolableConnection` is not satisfied
--> lib/src/lib.rs:32:13
|
32 | let pool = Pool::builder(config)
| ________________^
33 | | .max_size(20)
34 | | .build()?;
| |_________________^ the trait `PoolableConnection` is not implemented for `AsyncDieselConnectionManager<AsyncPgConnection>`, which is required by `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>: deadpool::managed::Manager`
|
= 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/eugenebos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deadpool-0.12.1/src/managed/mod.rs:249:20
|
249 | pub struct Pool<M: Manager, W: From<Object<M>> = Object<M>> {
| ^^^^^^^ required by this bound in `Pool`
error[E0308]: mismatched types
--> lib/src/lib.rs:36:2
|
22 | fn create_db_pool() -> Pool<AsyncDieselConnectionManager<AsyncPgConnection>> {
| ----------------------------------------------------- expected `deadpool::managed::Pool<AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>>` because of return type
...
36 | pool
| ^^^^ expected `AsyncDieselConnectionManager<AsyncPgConnection>`, found `AsyncPgConnection`
|
= note: expected struct `deadpool::managed::Pool<AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>, deadpool::managed::Object<AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>>>`
found struct `deadpool::managed::Pool<AsyncDieselConnectionManager<AsyncPgConnection>, deadpool::managed::Object<AsyncDieselConnectionManager<AsyncPgConnection>>>`
warning: unused import: `std::error::Error`
--> lib/src/structs.rs:2:5
|
2 | use std::error::Error;
| ^^^^^^^^^^^^^^^^^
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I cant even return pool connection from a function
But got
Beta Was this translation helpful? Give feedback.
All reactions