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