diff --git a/components/salsa-2022/src/ingredient.rs b/components/salsa-2022/src/ingredient.rs index d1c50f7..f7843f9 100644 --- a/components/salsa-2022/src/ingredient.rs +++ b/components/salsa-2022/src/ingredient.rs @@ -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 { + /// 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; }