salsa/
lib.rs

1#![deny(clippy::undocumented_unsafe_blocks)]
2#![forbid(unsafe_op_in_unsafe_fn)]
3
4#[cfg(feature = "accumulator")]
5mod accumulator;
6mod active_query;
7mod attach;
8mod cancelled;
9mod cycle;
10mod database;
11mod database_impl;
12mod durability;
13mod event;
14mod function;
15mod hash;
16mod id;
17mod ingredient;
18mod ingredient_cache;
19mod input;
20mod interned;
21mod key;
22mod memo_ingredient_indices;
23mod return_mode;
24mod revision;
25mod runtime;
26mod salsa_struct;
27mod storage;
28mod sync;
29mod table;
30mod tracing;
31mod tracked_struct;
32mod update;
33mod views;
34mod zalsa;
35mod zalsa_local;
36
37#[cfg(not(feature = "inventory"))]
38mod nonce;
39
40#[cfg(feature = "macros")]
41pub use salsa_macros::{accumulator, db, input, interned, tracked, Supertype, Update};
42
43#[cfg(feature = "salsa_unstable")]
44pub use self::database::IngredientInfo;
45
46#[cfg(feature = "accumulator")]
47pub use self::accumulator::Accumulator;
48pub use self::active_query::Backtrace;
49pub use self::cancelled::Cancelled;
50
51pub use self::cycle::Cycle;
52pub use self::database::Database;
53pub use self::database_impl::DatabaseImpl;
54pub use self::durability::Durability;
55pub use self::event::{Event, EventKind};
56pub use self::id::Id;
57pub use self::input::setter::Setter;
58pub use self::key::DatabaseKeyIndex;
59pub use self::return_mode::SalsaAsDeref;
60pub use self::return_mode::SalsaAsRef;
61pub use self::revision::Revision;
62pub use self::runtime::Runtime;
63pub use self::storage::{Storage, StorageHandle};
64pub use self::update::Update;
65pub use self::zalsa::IngredientIndex;
66pub use crate::attach::{attach, attach_allow_change, with_attached_database};
67
68pub mod prelude {
69    #[cfg(feature = "accumulator")]
70    pub use crate::accumulator::Accumulator;
71    pub use crate::{Database, Setter};
72}
73
74/// Internal names used by salsa macros.
75///
76/// # WARNING
77///
78/// The contents of this module are NOT subject to semver.
79#[doc(hidden)]
80pub mod plumbing {
81    pub use std::any::TypeId;
82    pub use std::option::Option::{self, None, Some};
83
84    #[cfg(feature = "accumulator")]
85    pub use salsa_macro_rules::setup_accumulator_impl;
86    pub use salsa_macro_rules::{
87        gate_accumulated, macro_if, maybe_backdate, maybe_default, maybe_default_tt,
88        return_mode_expression, return_mode_ty, setup_input_struct, setup_interned_struct,
89        setup_tracked_assoc_fn_body, setup_tracked_fn, setup_tracked_method_body,
90        setup_tracked_struct, unexpected_cycle_initial, unexpected_cycle_recovery,
91    };
92
93    #[cfg(feature = "accumulator")]
94    pub use crate::accumulator::Accumulator;
95    pub use crate::attach::{attach, with_attached_database};
96    pub use crate::cycle::CycleRecoveryStrategy;
97    pub use crate::database::{current_revision, Database};
98    pub use crate::durability::Durability;
99    pub use crate::id::{AsId, FromId, FromIdWithDb, Id};
100    pub use crate::ingredient::{Ingredient, Jar, Location};
101    pub use crate::ingredient_cache::IngredientCache;
102    pub use crate::key::DatabaseKeyIndex;
103    pub use crate::memo_ingredient_indices::{
104        IngredientIndices, MemoIngredientIndices, MemoIngredientMap, MemoIngredientSingletonIndex,
105        NewMemoIngredientIndices,
106    };
107    pub use crate::revision::Revision;
108    pub use crate::runtime::{stamp, Runtime, Stamp};
109    pub use crate::salsa_struct::SalsaStructInDb;
110    pub use crate::storage::{HasStorage, Storage};
111    pub use crate::table::memo::MemoTableWithTypes;
112    pub use crate::tracked_struct::TrackedStructInDb;
113    pub use crate::update::helper::{Dispatch as UpdateDispatch, Fallback as UpdateFallback};
114    pub use crate::update::{always_update, Update};
115    pub use crate::views::DatabaseDownCaster;
116    pub use crate::zalsa::{
117        register_jar, transmute_data_ptr, views, ErasedJar, HasJar, IngredientIndex, JarKind,
118        Zalsa, ZalsaDatabase,
119    };
120    pub use crate::zalsa_local::ZalsaLocal;
121
122    #[cfg(feature = "persistence")]
123    pub use serde;
124
125    // A stub for `serde` used when persistence is disabled.
126    //
127    // We provide dummy types to avoid detecting features during macro expansion.
128    #[cfg(not(feature = "persistence"))]
129    pub mod serde {
130        pub trait Serializer {
131            type Ok;
132            type Error;
133        }
134
135        pub trait Deserializer<'de> {
136            type Ok;
137            type Error;
138        }
139    }
140
141    #[cfg(feature = "accumulator")]
142    pub mod accumulator {
143        pub use crate::accumulator::{IngredientImpl, JarImpl};
144    }
145
146    pub mod input {
147        pub use crate::input::input_field::FieldIngredientImpl;
148        pub use crate::input::setter::SetterImpl;
149        pub use crate::input::singleton::{NotSingleton, Singleton};
150        pub use crate::input::{Configuration, HasBuilder, IngredientImpl, JarImpl, Value};
151    }
152
153    pub mod interned {
154        pub use crate::interned::{
155            Configuration, HashEqLike, IngredientImpl, JarImpl, Lookup, Value,
156        };
157    }
158
159    pub mod function {
160        pub use crate::function::Configuration;
161        pub use crate::function::IngredientImpl;
162        pub use crate::function::Memo;
163        pub use crate::table::memo::MemoEntryType;
164    }
165
166    pub mod tracked_struct {
167        pub use crate::tracked_struct::tracked_field::FieldIngredientImpl;
168        pub use crate::tracked_struct::{Configuration, IngredientImpl, JarImpl, Value};
169    }
170}