Skip to main content

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 self::zalsa_local::CancellationToken;
67pub use crate::attach::{attach, attach_allow_change, with_attached_database};
68pub use crate::interned::{HashEqLike, Lookup};
69
70pub mod prelude {
71    #[cfg(feature = "accumulator")]
72    pub use crate::accumulator::Accumulator;
73    pub use crate::{Database, Setter};
74}
75
76/// Internal names used by salsa macros.
77///
78/// # WARNING
79///
80/// The contents of this module are NOT subject to semver.
81#[doc(hidden)]
82pub mod plumbing {
83    pub use std::any::TypeId;
84    pub use std::option::Option::{self, None, Some};
85
86    #[cfg(feature = "accumulator")]
87    pub use salsa_macro_rules::setup_accumulator_impl;
88    pub use salsa_macro_rules::{
89        gate_accumulated, macro_if, maybe_default, maybe_default_tt, return_mode_expression,
90        return_mode_ty, setup_input_struct, setup_interned_struct, setup_tracked_assoc_fn_body,
91        setup_tracked_fn, setup_tracked_method_body, setup_tracked_struct,
92        unexpected_cycle_initial, unexpected_cycle_recovery,
93    };
94
95    #[cfg(feature = "accumulator")]
96    pub use crate::accumulator::Accumulator;
97    pub use crate::attach::{attach, with_attached_database};
98    pub use crate::cycle::CycleRecoveryStrategy;
99    pub use crate::database::{current_revision, Database};
100    pub use crate::durability::Durability;
101    pub use crate::id::{AsId, FromId, FromIdWithDb, Id};
102    pub use crate::ingredient::{Ingredient, Jar, Location};
103    pub use crate::ingredient_cache::IngredientCache;
104    pub use crate::interned::{HashEqLike, Lookup};
105    pub use crate::key::DatabaseKeyIndex;
106    pub use crate::memo_ingredient_indices::{
107        IngredientIndices, MemoIngredientIndices, MemoIngredientMap, MemoIngredientSingletonIndex,
108        NewMemoIngredientIndices,
109    };
110    pub use crate::revision::{AtomicRevision, Revision};
111    pub use crate::runtime::{stamp, Runtime, Stamp};
112    pub use crate::salsa_struct::SalsaStructInDb;
113    pub use crate::storage::{HasStorage, Storage};
114    pub use crate::table::memo::MemoTableWithTypes;
115    pub use crate::tracked_struct::TrackedStructInDb;
116    pub use crate::update::helper::{Dispatch as UpdateDispatch, Fallback as UpdateFallback};
117    pub use crate::update::{always_update, Update};
118    pub use crate::views::DatabaseDownCaster;
119    pub use crate::zalsa::{
120        register_jar, transmute_data_ptr, views, ErasedJar, HasJar, IngredientIndex, JarKind,
121        Zalsa, ZalsaDatabase,
122    };
123    pub use crate::zalsa_local::ZalsaLocal;
124
125    #[cfg(feature = "persistence")]
126    pub use serde;
127
128    // A stub for `serde` used when persistence is disabled.
129    //
130    // We provide dummy types to avoid detecting features during macro expansion.
131    #[cfg(not(feature = "persistence"))]
132    pub mod serde {
133        pub trait Serializer {
134            type Ok;
135            type Error;
136        }
137
138        pub trait Deserializer<'de> {
139            type Ok;
140            type Error;
141        }
142    }
143
144    #[cfg(feature = "accumulator")]
145    pub mod accumulator {
146        pub use crate::accumulator::{IngredientImpl, JarImpl};
147    }
148
149    pub mod input {
150        pub use crate::input::input_field::FieldIngredientImpl;
151        pub use crate::input::setter::SetterImpl;
152        pub use crate::input::singleton::{NotSingleton, Singleton};
153        pub use crate::input::{Configuration, HasBuilder, IngredientImpl, JarImpl, Value};
154    }
155
156    pub mod interned {
157        pub use crate::interned::{Configuration, IngredientImpl, JarImpl, Value};
158    }
159
160    pub mod function {
161        pub use crate::function::Configuration;
162        pub use crate::function::IngredientImpl;
163        pub use crate::function::Memo;
164        pub use crate::function::{EvictionPolicy, HasCapacity, Lru, NoopEviction};
165        pub use crate::table::memo::MemoEntryType;
166    }
167
168    pub mod tracked_struct {
169        pub use crate::tracked_struct::tracked_field::FieldIngredientImpl;
170        pub use crate::tracked_struct::{Configuration, IngredientImpl, JarImpl, Value};
171    }
172}