made_core/value_objects/ceremony/
ceremony_state.rs1use serde::{Deserialize, Serialize};
2
3use super::{CeremonyStateKind, StateId};
4
5#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
6pub struct CeremonyState {
7 id: StateId,
8 kind: CeremonyStateKind,
9}
10
11impl CeremonyState {
12 #[must_use]
13 pub fn new(id: StateId, kind: CeremonyStateKind) -> Self {
14 Self { id, kind }
15 }
16
17 #[must_use]
18 pub fn initial(id: StateId) -> Self {
19 Self::new(id, CeremonyStateKind::Initial)
20 }
21
22 #[must_use]
23 pub fn intermediate(id: StateId) -> Self {
24 Self::new(id, CeremonyStateKind::Intermediate)
25 }
26
27 #[must_use]
28 pub fn terminal(id: StateId) -> Self {
29 Self::new(id, CeremonyStateKind::Terminal)
30 }
31
32 #[must_use]
33 pub fn id(&self) -> &StateId {
34 &self.id
35 }
36
37 #[must_use]
38 pub fn kind(&self) -> CeremonyStateKind {
39 self.kind
40 }
41
42 #[must_use]
43 pub fn is_initial(&self) -> bool {
44 self.kind.is_initial()
45 }
46
47 #[must_use]
48 pub fn is_terminal(&self) -> bool {
49 self.kind.is_terminal()
50 }
51}