Skip to content

Commit

Permalink
Add working Debug impl for caching session
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
athre0z committed Dec 28, 2024
1 parent 86904de commit c5a8fcc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scylla/src/transport/caching_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -39,7 +40,6 @@ struct RawPreparedStatementData {
}

/// Provides auto caching while executing queries
#[derive(Debug)]
pub struct GenericCachingSession<DeserializationApi, S = RandomState>
where
S: Clone + BuildHasher,
Expand All @@ -53,6 +53,20 @@ where
cache: DashMap<String, RawPreparedStatementData, S>,
}

impl<DeserializationApi, S> fmt::Debug for GenericCachingSession<DeserializationApi, S>
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<S = RandomState> = GenericCachingSession<CurrentDeserializationApi, S>;

#[deprecated(
Expand Down

0 comments on commit c5a8fcc

Please sign in to comment.