Skip to content

Commit 3b83c93

Browse files
committed
scylla: 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.
1 parent 86904de commit 3b83c93

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scylla/src/transport/caching_session.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use scylla_cql::frame::response::result::{PreparedMetadata, ResultMetadata};
1616
use scylla_cql::types::serialize::batch::BatchValues;
1717
use scylla_cql::types::serialize::row::SerializeRow;
1818
use std::collections::hash_map::RandomState;
19+
use std::fmt;
1920
use std::hash::BuildHasher;
2021
use std::sync::Arc;
2122

@@ -39,7 +40,6 @@ struct RawPreparedStatementData {
3940
}
4041

4142
/// Provides auto caching while executing queries
42-
#[derive(Debug)]
4343
pub struct GenericCachingSession<DeserializationApi, S = RandomState>
4444
where
4545
S: Clone + BuildHasher,
@@ -53,6 +53,20 @@ where
5353
cache: DashMap<String, RawPreparedStatementData, S>,
5454
}
5555

56+
impl<DeserializationApi, S> fmt::Debug for GenericCachingSession<DeserializationApi, S>
57+
where
58+
S: Clone + BuildHasher,
59+
DeserializationApi: DeserializationApiKind,
60+
{
61+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
62+
f.debug_struct("GenericCachingSession")
63+
.field("session", &self.session)
64+
.field("max_capacity", &self.max_capacity)
65+
.field("cache", &self.cache)
66+
.finish()
67+
}
68+
}
69+
5670
pub type CachingSession<S = RandomState> = GenericCachingSession<CurrentDeserializationApi, S>;
5771

5872
#[deprecated(

0 commit comments

Comments
 (0)