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
//! The `Persistent` trait — implemented automatically by `#[persistent]`.
use ;
use crateAirId;
/// Marks a struct as persistable via `Store`.
///
/// Do not implement this manually — use `#[persistent]`.
///
/// # What the macro generates
///
/// ```ignore
/// #[persistent]
/// pub struct User {
/// pub name: String,
/// }
/// // expands to:
/// pub struct User {
/// pub id: AirId<User>,
/// pub name: String,
/// }
/// impl User {
/// pub fn new(name: String) -> Self { ... }
/// pub fn id(&self) -> AirId<Self> { self.id }
/// }
/// impl Persistent for User { ... }
/// ```
///
/// # Architecture patterns
///
/// In large codebases, `#[persistent]` should be used sparingly — only on
/// aggregates and domain entities that represent state worth saving. Child
/// structs nested inside a persistent root should be plain `Serialize +
/// Deserialize` values.
///
/// See the `airnest` crate README for a full guide on persistence boundaries,
/// aggregate-root modelling, repository layers, and domain-module conventions.