mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 21:05:11 +00:00
add ingredient_debug_name
API
This commit is contained in:
parent
83be1e4877
commit
118e89ce20
2 changed files with 19 additions and 2 deletions
|
@ -1,6 +1,9 @@
|
|||
use std::any::Any;
|
||||
use std::{any::Any, borrow::Cow};
|
||||
|
||||
use crate::{zalsa::ZalsaDatabase, Durability, Event, Revision};
|
||||
use crate::{
|
||||
zalsa::{IngredientIndex, ZalsaDatabase},
|
||||
Durability, Event, Revision,
|
||||
};
|
||||
|
||||
/// The trait implemented by all Salsa databases.
|
||||
/// You can create your own subtraits of this trait using the `#[salsa::db]`(`crate::db`) procedural macro.
|
||||
|
@ -38,6 +41,19 @@ pub trait Database: Send + AsDynDatabase + Any + ZalsaDatabase {
|
|||
zalsa_local.report_untracked_read(db.zalsa().current_revision())
|
||||
}
|
||||
|
||||
/// 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 [`DependencyIndex`](`crate::DependencyIndex`) values.
|
||||
fn ingredient_debug_name(&self, ingredient_index: IngredientIndex) -> Cow<'_, str> {
|
||||
Cow::Borrowed(
|
||||
self.zalsa()
|
||||
.lookup_ingredient(ingredient_index)
|
||||
.debug_name(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Execute `op` with the database in thread-local storage for debug print-outs.
|
||||
fn attach<R>(&self, op: impl FnOnce(&Self) -> R) -> R
|
||||
where
|
||||
|
|
|
@ -44,6 +44,7 @@ pub use self::revision::Revision;
|
|||
pub use self::runtime::Runtime;
|
||||
pub use self::storage::Storage;
|
||||
pub use self::update::Update;
|
||||
pub use self::zalsa::IngredientIndex;
|
||||
pub use crate::attach::with_attached_database;
|
||||
pub use salsa_macros::accumulator;
|
||||
pub use salsa_macros::db;
|
||||
|
|
Loading…
Reference in a new issue