more comments

This commit is contained in:
Niko Matsakis 2022-08-07 10:53:14 -04:00
parent 2547823a5f
commit 00d95436e0

View file

@ -4,11 +4,23 @@ use crate::{
use super::Revision;
/// "Ingredients" are the bits of data that are stored within the database to make salsa work.
/// Each jar will define some number of ingredients that it requires.
/// Each use salsa macro (e.g., `#[salsa::tracked]`, `#[salsa::interned]`) adds one or more ingredients to the jar struct
/// that together are used to create the salsa concept.
/// For example, a tracked struct defines a [`crate::interned::InternedIngredient`] to store its identity
/// plus [`crate::function::FunctionIngredient`] values to store its fields.
/// The exact ingredients are determined by [`IngredientsFor`](`crate::storage::IngredientsFor`) implementations generated by the macro.
pub trait Ingredient<DB: ?Sized> {
/// If this ingredient is a participant in a cycle, what is its cycle recovery strategy?
/// (Really only relevant to [`crate::function::FunctionIngredient`],
/// since only function ingredients push themselves onto the active query stack.)
fn cycle_recovery_strategy(&self) -> CycleRecoveryStrategy;
/// Has the value for `input` in this ingredient changed after `revision`?
fn maybe_changed_after(&self, db: &DB, input: DependencyIndex, revision: Revision) -> bool;
/// What were the inputs (if any) that were used to create the value at `key_index`.
fn inputs(&self, key_index: Id) -> Option<QueryInputs>;
}