pub trait Database:
Send
+ ZalsaDatabase
+ AsDynDatabase {
// Provided methods
fn trigger_lru_eviction(&mut self) { ... }
fn synthetic_write(&mut self, durability: Durability) { ... }
fn trigger_cancellation(&mut self) { ... }
fn cancellation_token(&self) -> CancellationToken { ... }
fn report_untracked_read(&self) { ... }
fn ingredient_debug_name(
&self,
ingredient_index: IngredientIndex,
) -> Cow<'_, str> { ... }
fn unwind_if_revision_cancelled(&self) { ... }
fn attach<R>(&self, op: impl FnOnce(&Self) -> R) -> R
where Self: Sized { ... }
}Expand description
The trait implemented by all Salsa databases.
You can create your own subtraits of this trait using the #[salsa::db](crate::db) procedural macro.
Provided Methods§
Sourcefn trigger_lru_eviction(&mut self)
fn trigger_lru_eviction(&mut self)
Enforces current LRU limits, evicting entries if necessary.
WARNING: Just like an ordinary write, this method triggers cancellation. If you invoke it while a snapshot exists, it will block until that snapshot is dropped – if that snapshot is owned by the current thread, this could trigger deadlock.
Sourcefn synthetic_write(&mut self, durability: Durability)
fn synthetic_write(&mut self, durability: Durability)
A “synthetic write” causes the system to act as though some
input of durability durability has changed, triggering a new revision.
This is mostly useful for profiling scenarios.
WARNING: Just like an ordinary write, this method triggers cancellation. If you invoke it while a snapshot exists, it will block until that snapshot is dropped – if that snapshot is owned by the current thread, this could trigger deadlock.
§Panics
Panics if durability is Durability::NEVER_CHANGE.
Sourcefn trigger_cancellation(&mut self)
fn trigger_cancellation(&mut self)
This method cancels all outstanding computations. If you invoke it while a snapshot exists, it will block until that snapshot is dropped – if that snapshot is owned by the current thread, this could trigger deadlock.
Sourcefn cancellation_token(&self) -> CancellationToken
fn cancellation_token(&self) -> CancellationToken
Retrieves a CancellationToken for the current database handle.
Sourcefn report_untracked_read(&self)
fn report_untracked_read(&self)
Reports that the query depends on some state unknown to salsa.
Queries which report untracked reads will be re-executed in the next revision.
Sourcefn ingredient_debug_name(
&self,
ingredient_index: IngredientIndex,
) -> Cow<'_, str>
fn ingredient_debug_name( &self, ingredient_index: IngredientIndex, ) -> Cow<'_, str>
Return the “debug name” (i.e., the struct name, etc) for an “ingredient”, which are the fine-grained components we use to track data. This is intended for debugging and the contents of the returned string are not semver-guaranteed.
Ingredient indices can be extracted from DatabaseKeyIndex values.
Sourcefn unwind_if_revision_cancelled(&self)
fn unwind_if_revision_cancelled(&self)
Starts unwinding the stack if the current revision is cancelled.
This method can be called by query implementations that perform potentially expensive computations, in order to speed up propagation of cancellation.
Cancellation will automatically be triggered by salsa on any query invocation.
This method should not be overridden by Database implementors. A
salsa_event is emitted when this method is called, so that should be
used instead.
Implementations§
Source§impl dyn Database
impl dyn Database
Sourcepub fn memory_usage(&self) -> DatabaseInfo
pub fn memory_usage(&self) -> DatabaseInfo
Returns memory usage information about ingredients in the database.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".