Skip to main content

CacheKey

Trait CacheKey 

Source
pub trait CacheKey:
    DynHash
    + DynEq
    + Debug
    + Send
    + Sync {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn type_name(&self) -> &'static str;
}
Expand description

Trait for types that can serve as cache keys.

This trait combines object-safe hashing, equality, and debug formatting. It is automatically implemented for all types that implement Hash + Eq + Debug + Send + Sync + 'static.

§Object Safety

This trait is object-safe, allowing Arc<dyn CacheKey> to be used in hash maps and other collections.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Get the key as Any for downcasting.

Source

fn type_name(&self) -> &'static str

Get the type name for this key.

Trait Implementations§

Source§

impl<'hash> Hash for dyn CacheKey + 'hash

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<'hash> Hash for dyn CacheKey + Send + 'hash

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<'hash> Hash for dyn CacheKey + Sync + 'hash

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<'hash> Hash for dyn CacheKey + Send + Sync + 'hash

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Hash + Eq + Debug + Send + Sync + 'static> CacheKey for T