mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-23 21:20:05 +00:00
rename FromQueryGroupDescriptor
and add comments
This commit is contained in:
parent
860a1ab1bf
commit
1c415b0c9d
3 changed files with 13 additions and 4 deletions
|
@ -80,7 +80,7 @@ pub(crate) fn database_storage(input: TokenStream) -> TokenStream {
|
|||
// rewrite the last identifier (`MyGroup`, above) to
|
||||
// (e.g.) `MyGroupGroupStorage`.
|
||||
descriptor_impls.extend(quote! {
|
||||
impl ::salsa::plumbing::FromQueryGroupDescriptor<#group_descriptor> for #database_name {
|
||||
impl ::salsa::plumbing::GetDatabaseDescriptor<#group_descriptor> for #database_name {
|
||||
fn from(descriptor: #group_descriptor) -> __SalsaQueryDescriptor {
|
||||
__SalsaQueryDescriptor {
|
||||
kind: __SalsaQueryDescriptorKind::#group_name(descriptor),
|
||||
|
@ -226,7 +226,7 @@ pub(crate) fn database_storage(input: TokenStream) -> TokenStream {
|
|||
db: &Self,
|
||||
key: <#query_type as ::salsa::Query<Self>>::Key,
|
||||
) -> <Self as ::salsa::plumbing::DatabaseStorageTypes>::QueryDescriptor {
|
||||
<Self as ::salsa::plumbing::FromQueryGroupDescriptor<_>>::from(#group_descriptor::#query_name(key))
|
||||
<Self as ::salsa::plumbing::GetDatabaseDescriptor<_>>::from(#group_descriptor::#query_name(key))
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -206,7 +206,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
|
|||
where
|
||||
T: #(salsa::plumbing::GetQueryTable<#qts> +)* #bounds,
|
||||
T: ::salsa::plumbing::GetQueryGroupStorage<#group_storage<T>>,
|
||||
T: ::salsa::plumbing::FromQueryGroupDescriptor<#group_descriptor>,
|
||||
T: ::salsa::plumbing::GetDatabaseDescriptor<#group_descriptor>,
|
||||
{
|
||||
#query_fn_definitions
|
||||
}
|
||||
|
|
|
@ -81,11 +81,20 @@ pub trait GetQueryTable<Q: Query<Self>>: Database {
|
|||
fn descriptor(db: &Self, key: Q::Key) -> Self::QueryDescriptor;
|
||||
}
|
||||
|
||||
/// Access the "group storage" with type `S` from the database.
|
||||
///
|
||||
/// This basically moves from the full context of the database to the context
|
||||
/// of one query group.
|
||||
pub trait GetQueryGroupStorage<S>: Database {
|
||||
fn from(db: &Self) -> &S;
|
||||
}
|
||||
|
||||
pub trait FromQueryGroupDescriptor<D>: Database {
|
||||
/// Given a group descriptor of type `D`, convert it to a full
|
||||
/// database query descriptor.
|
||||
///
|
||||
/// This basically moves a descriptor from the context of the query
|
||||
/// group into the full context of the database.
|
||||
pub trait GetDatabaseDescriptor<D>: Database {
|
||||
fn from(descriptor: D) -> Self::QueryDescriptor;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue