From c5a8fcc4173a648c83d52149492415fdc1752043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20H=C3=B6ner?= Date: Sat, 28 Dec 2024 15:28:14 +0100 Subject: [PATCH] Add working `Debug` impl for caching session The previous derived implementation was not actually usable because it had `Debug` bounds on the type parameters. The `RandomState` default value for the `S` argument does not impl `Debug`, so this didn't work. This commit switches to a manual `Debug` impl that doesn't have these unnecessary bounds. --- scylla/src/transport/caching_session.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scylla/src/transport/caching_session.rs b/scylla/src/transport/caching_session.rs index 77668b28cc..debf0def60 100644 --- a/scylla/src/transport/caching_session.rs +++ b/scylla/src/transport/caching_session.rs @@ -16,6 +16,7 @@ use scylla_cql::frame::response::result::{PreparedMetadata, ResultMetadata}; use scylla_cql::types::serialize::batch::BatchValues; use scylla_cql::types::serialize::row::SerializeRow; use std::collections::hash_map::RandomState; +use std::fmt; use std::hash::BuildHasher; use std::sync::Arc; @@ -39,7 +40,6 @@ struct RawPreparedStatementData { } /// Provides auto caching while executing queries -#[derive(Debug)] pub struct GenericCachingSession where S: Clone + BuildHasher, @@ -53,6 +53,20 @@ where cache: DashMap, } +impl fmt::Debug for GenericCachingSession +where + S: Clone + BuildHasher, + DeserializationApi: DeserializationApiKind, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("GenericCachingSession") + .field("session", &self.session) + .field("max_capacity", &self.max_capacity) + .field("cache", &self.cache) + .finish() + } +} + pub type CachingSession = GenericCachingSession; #[deprecated(