Skip to content

Conversation

@tibbe
Copy link

@tibbe tibbe commented Nov 21, 2024

This is needed when trying to use tower-sessions with this crate. tower-sessions requires Debug for the provided backend store. In my particular case the store looks like:

type SqlitePool = deadpool::Pool<SyncConnectionWrapper<sqlite::SqliteConnection>>;

#[derive(Clone, Debug)]
pub struct AsyncSqliteStore {
    pool: SqlitePool,
}

The error without this Debug impl is:

`diesel_async::sync_connection_wrapper::SyncConnectionWrapper<diesel::SqliteConnection>` doesn't implement `std::fmt::Debug`
the trait `std::fmt::Debug` is not implemented for `diesel_async::sync_connection_wrapper::SyncConnectionWrapper<diesel::SqliteConnection>`, which is required by `deadpool::managed::Pool<diesel_async::pooled_connection::AsyncDieselConnectionManager<diesel_async::sync_connection_wrapper::SyncConnectionWrapper<diesel::SqliteConnection>>>: std::fmt::Debug`

@tibbe
Copy link
Author

tibbe commented Nov 21, 2024

The particular trait I need to implement that required Debug is https://docs.rs/tower-sessions/0.13.0/tower_sessions/trait.SessionStore.html.

@tibbe
Copy link
Author

tibbe commented Nov 21, 2024

The MacOS build failures seem unrelated.

/// ```
#[derive(Debug)]
pub struct SyncConnectionWrapper<C> {
inner: Arc<Mutex<C>>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this PR.
Can you explain why this would be actual helpful for your use-case as #[derive(Debug)] only implements Debug if all generic parameters (in this case C) implements Debug on their own. I think all of the possible types for C (especially the SqliteConnection type) do not implement Debug on their own, so this won't actually be used at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a first step. I think need to work on e.g. SqliteConnection.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I had that discussion already a few times: The connection types do not implement Debug because there is nothing you can reasonably show there. They only hold a few opaque pointers to c objects. We also do not want to store the database URL in their as that could leak confidential information (login credentials, etc).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I will close this PR then.

@tibbe tibbe closed this Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants