Struct salsa_2022::function::FunctionIngredient
source · [−]pub struct FunctionIngredient<C: Configuration> { /* private fields */ }
Expand description
Function ingredients are the “workhorse” of salsa. They are used for tracked functions, for the “value” fields of tracked structs, and for the fields of input structs. The function ingredient is fairly complex and so its code is spread across multiple modules, typically one per method. The main entry points are:
- the
fetch
method, which is invoked when the function is called by the user’s code; it will return a memoized value if one exists, or execute the function otherwise. - the
specify
method, which can only be used when the key is an entity created by the active query. It sets the value of the function imperatively, so that when later fetches occur, they’ll return this value. - the
store
method, which can only be invoked with an&mut
reference, and is to set input fields.
Implementations
sourceimpl<C> FunctionIngredient<C>where
C: Configuration,
impl<C> FunctionIngredient<C>where
C: Configuration,
sourcepub fn accumulated<'db, A>(&self, db: &DynDb<'db, C>, key: C::Key) -> Vec<A::Data>where
DynDb<'db, C>: HasJar<A::Jar>,
A: Accumulator,
pub fn accumulated<'db, A>(&self, db: &DynDb<'db, C>, key: C::Key) -> Vec<A::Data>where
DynDb<'db, C>: HasJar<A::Jar>,
A: Accumulator,
Returns all the values accumulated into accumulator
by this query and its
transitive inputs.
sourceimpl<C> FunctionIngredient<C>where
C: Configuration,
impl<C> FunctionIngredient<C>where
C: Configuration,
sourceimpl<C> FunctionIngredient<C>where
C: Configuration,
impl<C> FunctionIngredient<C>where
C: Configuration,
sourceimpl<C> FunctionIngredient<C>where
C: Configuration,
impl<C> FunctionIngredient<C>where
C: Configuration,
sourceimpl<C> FunctionIngredient<C>where
C: Configuration,
impl<C> FunctionIngredient<C>where
C: Configuration,
pub fn new(index: IngredientIndex, debug_name: &'static str) -> Self
pub fn set_capacity(&self, capacity: usize)
Trait Implementations
sourceimpl<DB, C> Ingredient<DB> for FunctionIngredient<C>where
DB: ?Sized + DbWithJar<C::Jar>,
C: Configuration,
impl<DB, C> Ingredient<DB> for FunctionIngredient<C>where
DB: ?Sized + DbWithJar<C::Jar>,
C: Configuration,
sourcefn maybe_changed_after(
&self,
db: &DB,
input: DependencyIndex,
revision: Revision
) -> bool
fn maybe_changed_after(
&self,
db: &DB,
input: DependencyIndex,
revision: Revision
) -> bool
Has the value for
input
in this ingredient changed after revision
?sourcefn cycle_recovery_strategy(&self) -> CycleRecoveryStrategy
fn cycle_recovery_strategy(&self) -> CycleRecoveryStrategy
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.) Read moresourcefn origin(&self, key_index: Id) -> Option<QueryOrigin>
fn origin(&self, key_index: Id) -> Option<QueryOrigin>
What were the inputs (if any) that were used to create the value at
key_index
.sourcefn mark_validated_output(
&self,
db: &DB,
executor: DatabaseKeyIndex,
output_key: Option<Id>
)
fn mark_validated_output(
&self,
db: &DB,
executor: DatabaseKeyIndex,
output_key: Option<Id>
)
Invoked when the value
output_key
should be marked as valid in the current revision.
This occurs because the value for executor
, which generated it, was marked as valid
in the current revision. Read moresourcefn remove_stale_output(
&self,
_db: &DB,
_executor: DatabaseKeyIndex,
_stale_output_key: Option<Id>
)
fn remove_stale_output(
&self,
_db: &DB,
_executor: DatabaseKeyIndex,
_stale_output_key: Option<Id>
)
Invoked when the value
stale_output
was output by executor
in a previous
revision, but was NOT output in the current revision. Read moresourcefn reset_for_new_revision(&mut self)
fn reset_for_new_revision(&mut self)
Invoked when a new revision is about to start.
This moment is important because it means that we have an
&mut
-reference to the
database, and hence any pre-existing &
-references must have expired.
Many ingredients, given an &'db
-reference to the database,
use unsafe code to return &'db
-references to internal values.
The backing memory for those values can only be freed once an &mut
-reference to the
database is created. Read moresourcefn salsa_struct_deleted(&self, db: &DB, id: Id)
fn salsa_struct_deleted(&self, db: &DB, id: Id)
Informs the ingredient
self
that the salsa struct with id id
has been deleted.
This gives self
a chance to remove any memoized data dependent on id
.
To receive this callback, self
must register itself as a dependent function using
SalsaStructInDb::register_dependent_fn
. Read morefn fmt_index(&self, index: Option<Id>, fmt: &mut Formatter<'_>) -> Result
sourceimpl<C> IngredientRequiresReset for FunctionIngredient<C>where
C: Configuration,
impl<C> IngredientRequiresReset for FunctionIngredient<C>where
C: Configuration,
sourceconst RESET_ON_NEW_REVISION: bool = true
const RESET_ON_NEW_REVISION: bool = true
If this is true, then
reset_for_new_revision
will be called every new revision.Auto Trait Implementations
impl<C> !RefUnwindSafe for FunctionIngredient<C>
impl<C> Send for FunctionIngredient<C>where
<C as Configuration>::Key: Send,
<C as Configuration>::Value: Send + Sync,
impl<C> Sync for FunctionIngredient<C>where
<C as Configuration>::Key: Send + Sync,
<C as Configuration>::Value: Send + Sync,
impl<C> Unpin for FunctionIngredient<C>
impl<C> !UnwindSafe for FunctionIngredient<C>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more