Skip to content

Commit

Permalink
rename Storage to ZalsaImpl, privatize
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Jul 27, 2024
1 parent fd5353b commit d5f2ea7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 8 additions & 4 deletions src/database.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use std::{any::Any, panic::RefUnwindSafe};

use crate::{self as salsa, local_state, storage::Zalsa, Durability, Event, Revision, Storage};
use crate::{
self as salsa, local_state,
storage::{Zalsa, ZalsaImpl},
Durability, Event, Revision,
};

/// The trait implemented by all Salsa databases.
/// You can create your own subtraits of this trait using the `#[salsa::db]` procedural macro.
Expand Down Expand Up @@ -98,7 +102,7 @@ impl dyn Database {
/// Concrete implementation of the [`Database`][] trait.
/// Takes an optional type parameter `U` that allows you to thread your own data.
pub struct DatabaseImpl<U: UserData = ()> {
storage: Storage<U>,
storage: ZalsaImpl<U>,
}

impl<U: UserData + Default> Default for DatabaseImpl<U> {
Expand All @@ -113,7 +117,7 @@ impl DatabaseImpl<()> {
/// You can also use the [`Default`][] trait if your userdata implements it.
pub fn new() -> Self {
Self {
storage: Storage::with(()),
storage: ZalsaImpl::with(()),
}
}
}
Expand All @@ -124,7 +128,7 @@ impl<U: UserData> DatabaseImpl<U> {
/// You can also use the [`Default`][] trait if your userdata implements it.
pub fn with(u: U) -> Self {
Self {
storage: Storage::with(u),
storage: ZalsaImpl::with(u),
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ pub use self::input::setter::Setter;
pub use self::key::DatabaseKeyIndex;
pub use self::revision::Revision;
pub use self::runtime::Runtime;
pub use self::storage::Storage;
pub use self::update::Update;
pub use crate::local_state::with_attached_database;
pub use salsa_macros::accumulator;
Expand Down Expand Up @@ -89,7 +88,6 @@ pub mod plumbing {
pub use crate::storage::views;
pub use crate::storage::IngredientCache;
pub use crate::storage::IngredientIndex;
pub use crate::storage::Storage;
pub use crate::storage::Zalsa;
pub use crate::tracked_struct::TrackedStructInDb;
pub use crate::update::always_update;
Expand Down
8 changes: 4 additions & 4 deletions src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub trait Zalsa {
fn report_tracked_write(&mut self, durability: Durability);
}

impl<U: UserData> Zalsa for Storage<U> {
impl<U: UserData> Zalsa for ZalsaImpl<U> {
fn views(&self) -> &Views {
&self.views_of
}
Expand Down Expand Up @@ -212,7 +212,7 @@ impl IngredientIndex {

/// The "storage" struct stores all the data for the jars.
/// It is shared between the main database and any active snapshots.
pub struct Storage<U: UserData> {
pub(crate) struct ZalsaImpl<U: UserData> {
user_data: U,

views_of: ViewsOf<DatabaseImpl<U>>,
Expand Down Expand Up @@ -241,14 +241,14 @@ pub struct Storage<U: UserData> {
}

// ANCHOR: default
impl<U: UserData + Default> Default for Storage<U> {
impl<U: UserData + Default> Default for ZalsaImpl<U> {
fn default() -> Self {
Self::with(Default::default())
}
}
// ANCHOR_END: default

impl<U: UserData> Storage<U> {
impl<U: UserData> ZalsaImpl<U> {
pub(crate) fn with(user_data: U) -> Self {
Self {
views_of: Default::default(),
Expand Down

0 comments on commit d5f2ea7

Please sign in to comment.