use std::fmt::Debug;
pub trait CacheableKey {
fn to_cache_key(&self) -> String;
}
pub trait DefaultCacheableKey: Debug {}
impl<T> CacheableKey for T
where
T: DefaultCacheableKey + ?Sized,
{
fn to_cache_key(&self) -> String {
format!("{:?}", self)
}
}
impl DefaultCacheableKey for u8 {}
impl DefaultCacheableKey for u16 {}
impl DefaultCacheableKey for u32 {}
impl DefaultCacheableKey for u64 {}
impl DefaultCacheableKey for u128 {}
impl DefaultCacheableKey for usize {}
impl DefaultCacheableKey for i8 {}
impl DefaultCacheableKey for i16 {}
impl DefaultCacheableKey for i32 {}
impl DefaultCacheableKey for i64 {}
impl DefaultCacheableKey for i128 {}
impl DefaultCacheableKey for isize {}
impl DefaultCacheableKey for f32 {}
impl DefaultCacheableKey for f64 {}
impl DefaultCacheableKey for bool {}
impl DefaultCacheableKey for char {}
impl DefaultCacheableKey for String {}
impl DefaultCacheableKey for &str {}
impl<T1: DefaultCacheableKey> DefaultCacheableKey for (T1,) {}
impl<T1: DefaultCacheableKey, T2: DefaultCacheableKey> DefaultCacheableKey for (T1, T2) {}
impl<T1: DefaultCacheableKey, T2: DefaultCacheableKey, T3: DefaultCacheableKey> DefaultCacheableKey
for (T1, T2, T3)
{
}
impl<
T1: DefaultCacheableKey,
T2: DefaultCacheableKey,
T3: DefaultCacheableKey,
T4: DefaultCacheableKey,
> DefaultCacheableKey for (T1, T2, T3, T4)
{
}
impl<
T1: DefaultCacheableKey,
T2: DefaultCacheableKey,
T3: DefaultCacheableKey,
T4: DefaultCacheableKey,
T5: DefaultCacheableKey,
> DefaultCacheableKey for (T1, T2, T3, T4, T5)
{
}
impl<T: DefaultCacheableKey> DefaultCacheableKey for Option<T> {}
impl<T: DefaultCacheableKey> DefaultCacheableKey for Vec<T> {}
impl<T: DefaultCacheableKey> DefaultCacheableKey for &[T] {}