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§
Provided Methods§
Sourcefn combine(node_hash: u64, level: usize) -> u64
fn combine(node_hash: u64, level: usize) -> u64
Combine a node hash with a rule-group level to produce a cache key.
Sourcefn hash(term: &T, level: usize) -> u64
fn hash(term: &T, level: usize) -> u64
Compute a cache key for term at the given rule application level.
Sourcefn invalidate(_node: &T)
fn invalidate(_node: &T)
Invalidate any internally cached hash for the given node.
The default is a no-op (used by StdHashKey).
Sourcefn invalidate_subtree(_node: &T)
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.