mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-15 01:39:25 +00:00
add a SalsaStructInDb trait
Not currently used anywhere, but will be implemented by all salsa structs.
This commit is contained in:
parent
fc5e05fae0
commit
25e085fbdc
4 changed files with 21 additions and 1 deletions
|
@ -39,6 +39,7 @@ impl TrackedStruct {
|
|||
let id_struct = self.id_struct();
|
||||
let inherent_impl = self.tracked_inherent_impl();
|
||||
let ingredients_for_impl = self.tracked_struct_ingredients(&config_structs);
|
||||
let salsa_struct_in_db_impl = self.salsa_struct_in_db_impl();
|
||||
let tracked_struct_in_db_impl = self.tracked_struct_in_db_impl();
|
||||
let as_id_impl = self.as_id_impl();
|
||||
Ok(quote! {
|
||||
|
@ -46,6 +47,7 @@ impl TrackedStruct {
|
|||
#id_struct
|
||||
#inherent_impl
|
||||
#ingredients_for_impl
|
||||
#salsa_struct_in_db_impl
|
||||
#tracked_struct_in_db_impl
|
||||
#as_id_impl
|
||||
#(#config_impls)*
|
||||
|
@ -205,6 +207,19 @@ impl TrackedStruct {
|
|||
}
|
||||
}
|
||||
|
||||
/// Implementation of `SalsaStructInDb`.
|
||||
fn salsa_struct_in_db_impl(&self) -> syn::ItemImpl {
|
||||
let ident = self.id_ident();
|
||||
let jar_ty = self.jar_ty();
|
||||
parse_quote! {
|
||||
impl<DB> salsa::salsa_struct::SalsaStructInDb<DB> for #ident
|
||||
where
|
||||
DB: ?Sized + salsa::DbWithJar<#jar_ty>,
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Implementation of `TrackedStructInDb`.
|
||||
fn tracked_struct_in_db_impl(&self) -> syn::ItemImpl {
|
||||
let ident = self.id_ident();
|
||||
|
|
|
@ -17,6 +17,7 @@ pub mod plumbing;
|
|||
pub mod revision;
|
||||
pub mod routes;
|
||||
pub mod runtime;
|
||||
pub mod salsa_struct;
|
||||
pub mod storage;
|
||||
#[doc(hidden)]
|
||||
pub mod tracked_struct;
|
||||
|
|
3
components/salsa-2022/src/salsa_struct.rs
Normal file
3
components/salsa-2022/src/salsa_struct.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
use crate::Database;
|
||||
|
||||
pub trait SalsaStructInDb<DB: ?Sized + Database> {}
|
|
@ -4,6 +4,7 @@ use crate::{
|
|||
interned::{InternedData, InternedId, InternedIngredient},
|
||||
key::{DatabaseKeyIndex, DependencyIndex},
|
||||
runtime::{local_state::QueryInputs, Runtime},
|
||||
salsa_struct::SalsaStructInDb,
|
||||
Database, IngredientIndex, Revision,
|
||||
};
|
||||
|
||||
|
@ -13,7 +14,7 @@ impl<T: InternedId> TrackedStructId for T {}
|
|||
pub trait TrackedStructData: InternedData {}
|
||||
impl<T: InternedData> TrackedStructData for T {}
|
||||
|
||||
pub trait TrackedStructInDb<DB: ?Sized + Database> {
|
||||
pub trait TrackedStructInDb<DB: ?Sized + Database>: SalsaStructInDb<DB> {
|
||||
fn database_key_index(self, db: &DB) -> DatabaseKeyIndex;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue