Skip to main content

CacheKey

Trait CacheKey 

Source
pub trait CacheKey:
    Hash
    + Eq
    + Send
    + Sync
    + Clone
    + Debug
    + 'static {
    const CACHE_NAME: &'static str;

    // Required methods
    fn matches_source(&self, source_id: &str) -> bool;
    fn record_outcome(&self, hit: bool);
}
Expand description

A cache key for ResourceCache.

Required Associated Constants§

Source

const CACHE_NAME: &'static str

Identifier used as the moka cache name, the trace-log prefix, and the metric label in Self::record_outcome.

Required Methods§

Source

fn matches_source(&self, source_id: &str) -> bool

Whether this key should be wiped when source_id is invalidated.

Source

fn record_outcome(&self, hit: bool)

Records one hit or miss. Called exactly once per get_or_insert.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl CacheKey for FontCacheKey

Source§

const CACHE_NAME: &'static str = "font"

Source§

impl CacheKey for SpriteCacheKey

Source§

const CACHE_NAME: &'static str = "sprite"

Source§

impl CacheKey for TileCacheKey

Source§

const CACHE_NAME: &'static str = "tile"