Trait rustc_query_system::query::caches::QueryCache
source · pub trait QueryCache: QueryStorage + Sized {
type Key: Hash + Eq + Clone + Debug;
fn lookup<R, OnHit>(&self, key: &Self::Key, on_hit: OnHit) -> Result<R, ()>
where
OnHit: FnOnce(&Self::Stored, DepNodeIndex) -> R;
fn complete(
&self,
key: Self::Key,
value: Self::Value,
index: DepNodeIndex
) -> Self::Stored;
fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex));
}
Required Associated Types§
Required Methods§
sourcefn lookup<R, OnHit>(&self, key: &Self::Key, on_hit: OnHit) -> Result<R, ()>where
OnHit: FnOnce(&Self::Stored, DepNodeIndex) -> R,
fn lookup<R, OnHit>(&self, key: &Self::Key, on_hit: OnHit) -> Result<R, ()>where
OnHit: FnOnce(&Self::Stored, DepNodeIndex) -> R,
Checks if the query is already computed and in the cache. It returns the shard index and a lock guard to the shard, which will be used if the query is not in the cache and we need to compute it.