1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Generic extension storage for [`AimDbBuilder`] and [`AimDb`].
//!
//! External crates store typed state here during builder configuration
//! and retrieve it during record setup or at query time. This is the
//! hook mechanism used by `aimdb-persistence` — and any other crate that
//! needs to attach data to the builder or the live database without
//! modifying `aimdb-core`.
//!
//! # Example
//! ```rust,ignore
//! // Storing a value (e.g. from an external "with_persistence" builder ext):
//! builder.extensions_mut().insert(MyState { ... });
//!
//! // Retrieving it from a RecordRegistrar closure:
//! let state = reg.extensions().get::<MyState>().expect("MyState not configured");
//!
//! // Retrieving it from a live AimDb handle (query time):
//! let state = db.extensions().get::<MyState>().expect("MyState not configured");
//! ```
extern crate alloc;
use Box;
use ;
use HashMap;
/// Generic extension storage for [`AimDbBuilder`][crate::AimDbBuilder] and
/// [`AimDb`][crate::AimDb].
///
/// Keyed by [`TypeId`] so each stored type occupies exactly one slot.
/// Values must be `Send + Sync + 'static` to be safe across thread and task
/// boundaries used throughout AimDB's async executor model.