Struct salsa_2022::input_field::InputFieldIngredient
source · [−]pub struct InputFieldIngredient<K, F> { /* private fields */ }
Expand description
Ingredient used to represent the fields of a #[salsa::input]
.
These fields can only be mutated by a call to a setter with an &mut
reference to the database, and therefore cannot be mutated during a tracked
function or in parallel.
However for on-demand inputs to work the fields must be able to be set via
a shared reference, so some locking is required.
Altogether this makes the implementation somewhat simpler than tracked
structs.
Implementations
sourceimpl<K, F> InputFieldIngredient<K, F>where
K: Eq + Hash + AsId,
impl<K, F> InputFieldIngredient<K, F>where
K: Eq + Hash + AsId,
pub fn new(index: IngredientIndex, debug_name: &'static str) -> Self
pub fn store_mut(
&mut self,
runtime: &Runtime,
key: K,
value: F,
durability: Durability
) -> Option<F>
sourcepub fn store_new(&self, runtime: &Runtime, key: K, value: F, durability: Durability)
pub fn store_new(&self, runtime: &Runtime, key: K, value: F, durability: Durability)
Set the field of a new input.
This function panics if the field has ever been set before.
pub fn fetch<'db>(&'db self, runtime: &'db Runtime, key: K) -> &'_ F
Trait Implementations
sourceimpl<DB: ?Sized, K, F> Ingredient<DB> for InputFieldIngredient<K, F>where
K: AsId,
impl<DB: ?Sized, K, F> Ingredient<DB> for InputFieldIngredient<K, F>where
K: AsId,
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 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 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 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 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 morefn fmt_index(&self, index: Option<Id>, fmt: &mut Formatter<'_>) -> Result
sourceimpl<K, F> IngredientRequiresReset for InputFieldIngredient<K, F>where
K: AsId,
impl<K, F> IngredientRequiresReset for InputFieldIngredient<K, F>where
K: AsId,
sourceconst RESET_ON_NEW_REVISION: bool = false
const RESET_ON_NEW_REVISION: bool = false
If this is true, then
reset_for_new_revision
will be called every new revision.Auto Trait Implementations
impl<K, F> !RefUnwindSafe for InputFieldIngredient<K, F>
impl<K, F> Send for InputFieldIngredient<K, F>where
F: Send,
K: Send,
impl<K, F> Sync for InputFieldIngredient<K, F>where
F: Send + Sync,
K: Send + Sync,
impl<K, F> Unpin for InputFieldIngredient<K, F>
impl<K, F> UnwindSafe for InputFieldIngredient<K, F>where
F: UnwindSafe,
K: UnwindSafe,
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