icydb_core/traits/mod.rs
1//! Module: traits
2//!
3//! Responsibility: foundational kind, field metadata, and projection
4//! contracts awaiting narrower domain ownership.
5//! Does not own: entity composition, key taxonomy, runtime value conversion,
6//! visitor traversal, executor policy, or public facade DTO behavior.
7//! Boundary: remaining reusable contracts consumed throughout `icydb-core`.
8
9// ============================================================================
10// FOUNDATIONAL KINDS
11// ============================================================================
12//
13// These traits define *where* something lives in the system,
14// not what data it contains.
15//
16
17///
18/// Path
19/// Fully-qualified schema path.
20///
21
22pub trait Path {
23 const PATH: &'static str;
24}
25
26///
27/// CanisterKind
28/// Marker for canister namespaces
29///
30
31pub trait CanisterKind: Path + 'static {
32 /// Resolve the commit slot from committed allocation authority.
33 fn commit_memory_id() -> Result<u8, ic_memory::RuntimeOpenError> {
34 crate::memory::committed_memory_id(Self::COMMIT_STABLE_KEY)
35 }
36
37 /// Durable stable-memory allocation key for commit marker storage.
38 const COMMIT_STABLE_KEY: &'static str;
39
40 /// Resolve the startup slot from committed allocation authority.
41 fn startup_memory_id() -> Result<u8, ic_memory::RuntimeOpenError> {
42 crate::memory::committed_memory_id(Self::STARTUP_STABLE_KEY)
43 }
44
45 /// Durable stable-memory allocation key for startup coordination state.
46 const STARTUP_STABLE_KEY: &'static str;
47
48 /// Resolve the integrity slot from committed allocation authority.
49 fn integrity_progress_memory_id() -> Result<u8, ic_memory::RuntimeOpenError> {
50 crate::memory::committed_memory_id(Self::INTEGRITY_PROGRESS_STABLE_KEY)
51 }
52
53 /// Durable stable-memory allocation key for integrity-inspection progress.
54 const INTEGRITY_PROGRESS_STABLE_KEY: &'static str;
55}
56
57///
58/// Repr
59///
60/// Internal representation boundary for scalar wrapper types.
61///
62
63pub trait Repr {
64 type Inner;
65
66 fn repr(&self) -> Self::Inner;
67 fn from_repr(inner: Self::Inner) -> Self;
68}