Skip to content

Instantly share code, notes, and snippets.

@feliwir
Created July 12, 2024 08:39
Show Gist options
  • Save feliwir/dc3cd56bcc6a3049d87b1e02710bc44f to your computer and use it in GitHub Desktop.
Save feliwir/dc3cd56bcc6a3049d87b1e02710bc44f to your computer and use it in GitHub Desktop.
Checking db v0.1.0 (/home/stephan/Development/mray_server/db)
warning: unused import: `self`
--> db/src/error.rs:1:16
|
1 | use std::fmt::{self, Display, Formatter};
| ^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `bb8`
--> db/src/error.rs:3:39
|
3 | use diesel_async::pooled_connection::{bb8, PoolError};
| ^^^
error[E0223]: ambiguous associated type
--> db/src/lib.rs:15:9
|
15 | AsyncDieselConnectionManager<DbConnection>::Error,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: use fully-qualified syntax
|
15 | <AsyncDieselConnectionManager<AsyncPgConnection> as TryFrom>::Error,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 | <AsyncDieselConnectionManager<AsyncPgConnection> as TryInto>::Error,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 | <AsyncDieselConnectionManager<AsyncPgConnection> as bb8::api::ManageConnection>::Error,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 | <AsyncDieselConnectionManager<AsyncPgConnection> as fallible_iterator::IntoFallibleIterator>::Error,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
and 2 other candidates
error[E0277]: the trait bound `AsyncDieselConnectionManager<AsyncPgConnection>: PoolableConnection` is not satisfied
--> db/src/lib.rs:13:12
|
13 | let x: Result<
| ____________^
14 | | Pool<AsyncDieselConnectionManager<DbConnection>>,
15 | | AsyncDieselConnectionManager<DbConnection>::Error,
16 | | > = Pool::builder().build(config).await;
| |_____^ the trait `PoolableConnection` is not implemented for `AsyncDieselConnectionManager<AsyncPgConnection>`, which is required by `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>: bb8::api::ManageConnection`
|
= help: the trait `PoolableConnection` is implemented for `AsyncPgConnection`
= note: required for `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>` to implement `bb8::api::ManageConnection`
note: required by a bound in `bb8::api::Pool`
--> /home/stephan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bb8-0.8.5/src/api.rs:16:8
|
14 | pub struct Pool<M>
| ---- required by a bound in this struct
15 | where
16 | M: ManageConnection,
| ^^^^^^^^^^^^^^^^ required by this bound in `Pool`
error[E0277]: the trait bound `AsyncDieselConnectionManager<AsyncPgConnection>: DerefMut` is not satisfied
--> db/src/lib.rs:13:12
|
13 | let x: Result<
| ____________^
14 | | Pool<AsyncDieselConnectionManager<DbConnection>>,
15 | | AsyncDieselConnectionManager<DbConnection>::Error,
16 | | > = Pool::builder().build(config).await;
| |_____^ the trait `DerefMut` is not implemented for `AsyncDieselConnectionManager<AsyncPgConnection>`, which is required by `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>: bb8::api::ManageConnection`
|
= help: the trait `bb8::api::ManageConnection` is implemented for `AsyncDieselConnectionManager<C>`
= note: required for `AsyncDieselConnectionManager<AsyncPgConnection>` to implement `AsyncConnection`
= note: required for `AsyncDieselConnectionManager<AsyncDieselConnectionManager<AsyncPgConnection>>` to implement `bb8::api::ManageConnection`
note: required by a bound in `bb8::api::Pool`
--> /home/stephan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bb8-0.8.5/src/api.rs:16:8
|
14 | pub struct Pool<M>
| ---- required by a bound in this struct
15 | where
16 | M: ManageConnection,
| ^^^^^^^^^^^^^^^^ required by this bound in `Pool`
Some errors have detailed explanations: E0223, E0277.
For more information about an error, try `rustc --explain E0223`.
warning: `db` (lib) generated 2 warnings
error: could not compile `db` (lib) due to 3 previous errors; 2 warnings emitted
use diesel_async::pooled_connection::bb8::Pool;
use diesel_async::pooled_connection::AsyncDieselConnectionManager;
use diesel_async::AsyncPgConnection;
mod error;
pub use error::DatabaseError;
pub type DbConnection = AsyncPgConnection;
pub type DbPool = Pool<AsyncDieselConnectionManager<DbConnection>>;
pub async fn initialize_db_pool(database_url: &str) -> Result<(), DatabaseError> {
let config = AsyncDieselConnectionManager::<DbConnection>::new(database_url);
let x: Result<
Pool<AsyncDieselConnectionManager<DbConnection>>,
AsyncDieselConnectionManager<DbConnection>::Error,
> = Pool::builder().build(config).await;
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment