zerodds_durability_store/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 ZeroDDS Contributors
3
4//! DDS Durability-Service storage abstraction (DDS 1.4 §2.2.3.4/§2.2.3.5).
5//!
6//! Crate `zerodds-durability-store`. Safety classification: **STANDARD**.
7//!
8//! This crate is the **storage layer** of the standalone Durability-Service
9//! (ADR 0009). It is deliberately free of any DDS/RTPS dependency — the
10//! daemon (`zerodds-durability-service`) and adapters
11//! (`zerodds-durability-store-{sqlite,file,lakehouse}`) build on top of it.
12//!
13//! ## Layering (ADR 0009)
14//!
15//! ```text
16//! TieredStore — memory hot-cache (bounded by a byte budget) over any cold store
17//! └─ DurabilityStore (this trait) — store / query / unregister / cleanup / stats
18//! └─ cold adapter (sqlite / file / lakehouse / in-memory)
19//! ```
20//!
21//! ## Invariants (normative, ADR 0009)
22//!
23//! 1. **The QoS is the contract.** [`Contract`] (derived from
24//! `DurabilityServiceQosPolicy` + history) is the ONLY thing that bounds
25//! retention. The cold store enforces it (drop-oldest / `OutOfResources`).
26//! 2. **The memory budget is not a retention knob.** [`TieredStore`]'s hot
27//! cache only decides how much contracted history is kept hot in RAM; the
28//! rest lives in the cold store and is streamed on read — never capped.
29//! 3. **The cold store is authoritative** for the full contracted history.
30//! Reads ([`DurabilityStore::query`]) are paginated ([`Page`]/[`Cursor`]),
31//! never "everything into RAM".
32
33#![forbid(unsafe_code)]
34
35extern crate alloc;
36
37mod contract;
38mod error;
39mod memory;
40mod model;
41mod store;
42mod tiered;
43
44pub use contract::Contract;
45pub use error::{Result, StoreError};
46pub use memory::InMemoryStore;
47pub use model::{Cursor, DurabilitySample, Page, Selector, StoreStats};
48pub use store::DurabilityStore;
49pub use tiered::TieredStore;