Skip to main content

CacheKey

Trait CacheKey 

Source
pub trait CacheKey<T> {
    // Required method
    fn node_hash(term: &T) -> u64;

    // Provided methods
    fn combine(node_hash: u64, level: usize) -> u64 { ... }
    fn hash(term: &T, level: usize) -> u64 { ... }
    fn invalidate(_node: &T) { ... }
    fn invalidate_subtree(_node: &T) { ... }
}
Expand description

Abstracts how a cache computes hash keys and invalidates nodes.

Implement this trait to plug different hashing strategies into HashMapCache.

Required Methods§

Source

fn node_hash(term: &T) -> u64

Compute a level-independent hash for term.

Provided Methods§

Source

fn combine(node_hash: u64, level: usize) -> u64

Combine a node hash with a rule-group level to produce a cache key.

Source

fn hash(term: &T, level: usize) -> u64

Compute a cache key for term at the given rule application level.

Source

fn invalidate(_node: &T)

Invalidate any internally cached hash for the given node. The default is a no-op (used by StdHashKey).

Source

fn invalidate_subtree(_node: &T)

Invalidate cached hashes for the given node and all its descendants. The default is a no-op (used by StdHashKey).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§