mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-12-27 06:27:45 +00:00
make DatabaseStorageTypes have supertrait of Database
This commit is contained in:
parent
12f54d66f4
commit
7a5b515279
3 changed files with 6 additions and 6 deletions
|
@ -45,7 +45,7 @@ pub use crate::storage::Storage;
|
|||
/// The base trait which your "query context" must implement. Gives
|
||||
/// access to the salsa runtime, which you must embed into your query
|
||||
/// context (along with whatever other state you may require).
|
||||
pub trait Database: plumbing::DatabaseStorageTypes + plumbing::DatabaseOps {
|
||||
pub trait Database: plumbing::DatabaseOps {
|
||||
/// Iterates through all query storage and removes any values that
|
||||
/// have not been used since the last revision was created. The
|
||||
/// intended use-cycle is that you first execute all of your
|
||||
|
|
|
@ -29,7 +29,7 @@ pub struct CycleDetected {
|
|||
/// should be generated for your query-context type automatically by
|
||||
/// the `database_storage` macro, so you shouldn't need to mess
|
||||
/// with this trait directly.
|
||||
pub trait DatabaseStorageTypes: Sized {
|
||||
pub trait DatabaseStorageTypes: Database {
|
||||
/// Defines the "storage type", where all the query data is kept.
|
||||
/// This type is defined by the `database_storage` macro.
|
||||
type DatabaseStorage: Default;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
use crate::{Database, Runtime};
|
||||
use crate::{plumbing::DatabaseStorageTypes, Runtime};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Stores the cached results and dependency information for all the queries
|
||||
/// defined on your salsa database. Also embeds a [`Runtime`] which is used to
|
||||
/// manage query execution. Every database must include a `storage:
|
||||
/// Storage<Self>` field.
|
||||
pub struct Storage<DB: Database> {
|
||||
pub struct Storage<DB: DatabaseStorageTypes> {
|
||||
query_store: Arc<DB::DatabaseStorage>,
|
||||
runtime: Runtime,
|
||||
}
|
||||
|
||||
impl<DB: Database> Default for Storage<DB> {
|
||||
impl<DB: DatabaseStorageTypes> Default for Storage<DB> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
query_store: Default::default(),
|
||||
|
@ -19,7 +19,7 @@ impl<DB: Database> Default for Storage<DB> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<DB: Database> Storage<DB> {
|
||||
impl<DB: DatabaseStorageTypes> Storage<DB> {
|
||||
/// Gives access to the underlying salsa runtime.
|
||||
pub fn salsa_runtime(&self) -> &Runtime {
|
||||
&self.runtime
|
||||
|
|
Loading…
Reference in a new issue