Skip to main content

made_core/value_objects/ceremony/
ceremony_succession.rs

1use serde::{Deserialize, Serialize};
2
3use super::{CeremonyId, DefinitionPin, IdempotencyKey};
4use crate::value_objects::{AuditRecordHash, StreamVersion};
5
6/// Which ceremony this one succeeds, as the successor's own opening
7/// records it.
8///
9/// The predecessor's head and version are part of the reference: a
10/// successor says which cut of the predecessor it was planned against,
11/// so "what had happened when this was decided" is answerable from the
12/// successor's first record instead of by guessing at timestamps. Both
13/// pins travel because the whole reason a successor exists is that the
14/// definition changed, and a handoff that did not record both sides of
15/// that change would lose the fact it was made for.
16#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
17pub struct CeremonySuccession {
18    predecessor_id: CeremonyId,
19    predecessor_head: AuditRecordHash,
20    predecessor_version: StreamVersion,
21    predecessor_definition: DefinitionPin,
22    successor_definition: DefinitionPin,
23    plan_id: IdempotencyKey,
24}
25
26impl CeremonySuccession {
27    #[must_use]
28    pub const fn new(
29        predecessor_id: CeremonyId,
30        predecessor_head: AuditRecordHash,
31        predecessor_version: StreamVersion,
32        predecessor_definition: DefinitionPin,
33        successor_definition: DefinitionPin,
34        plan_id: IdempotencyKey,
35    ) -> Self {
36        Self {
37            predecessor_id,
38            predecessor_head,
39            predecessor_version,
40            predecessor_definition,
41            successor_definition,
42            plan_id,
43        }
44    }
45
46    #[must_use]
47    pub const fn predecessor_id(&self) -> &CeremonyId {
48        &self.predecessor_id
49    }
50
51    #[must_use]
52    pub const fn predecessor_head(&self) -> AuditRecordHash {
53        self.predecessor_head
54    }
55
56    #[must_use]
57    pub const fn predecessor_version(&self) -> StreamVersion {
58        self.predecessor_version
59    }
60
61    #[must_use]
62    pub const fn predecessor_definition(&self) -> &DefinitionPin {
63        &self.predecessor_definition
64    }
65
66    #[must_use]
67    pub const fn successor_definition(&self) -> &DefinitionPin {
68        &self.successor_definition
69    }
70
71    #[must_use]
72    pub const fn plan_id(&self) -> &IdempotencyKey {
73        &self.plan_id
74    }
75}