Skip to main content

ic_memory/generation/
mod.rs

1use crate::{declaration::DeclarationSnapshot, ledger::GenerationRecord};
2use serde::{Deserialize, Serialize};
3
4///
5/// GenerationMutation
6///
7/// One staged allocation-history mutation.
8#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
9pub enum GenerationMutation {
10    /// Add or confirm an active allocation declaration.
11    Declare,
12    /// Add or confirm a reserved allocation declaration.
13    Reserve,
14    /// Explicitly retire an allocation.
15    Retire,
16    /// Record schema metadata drift for diagnostics.
17    RecordSchemaMetadata,
18}
19
20///
21/// StagedGeneration
22///
23/// Generation prepared for atomic commit.
24#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
25pub struct StagedGeneration {
26    /// Generation number to commit.
27    pub generation: u64,
28    /// Parent generation that remains authoritative until commit succeeds.
29    pub parent_generation: u64,
30    /// Snapshot being committed.
31    pub snapshot: DeclarationSnapshot,
32    /// Staged mutations included in this generation.
33    pub mutations: Vec<GenerationMutation>,
34}
35
36///
37/// GenerationCommit
38///
39/// Protected commit metadata for a generation.
40#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
41pub struct GenerationCommit {
42    /// Committed generation record.
43    pub record: GenerationRecord,
44    /// Protected commit checksum supplied by the physical format.
45    pub checksum: u64,
46    /// Physical commit marker supplied by the physical format.
47    pub commit_marker: u64,
48}