made_core/value_objects/ceremony/
ceremony_step.rs1use serde::{Deserialize, Serialize};
2
3use super::{
4 RetryPolicy, StateId, StepHandlerConfig, StepHandlerKind, StepId, StepRepeatPolicy, StepTimeout,
5};
6
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
8pub struct CeremonyStep {
9 id: StepId,
10 state_id: StateId,
11 handler_kind: StepHandlerKind,
12 handler_config: StepHandlerConfig,
13 retry_policy: RetryPolicy,
14 timeout: Option<StepTimeout>,
15 #[serde(default, skip_serializing_if = "Option::is_none")]
16 repeat_policy: Option<StepRepeatPolicy>,
17}
18
19impl CeremonyStep {
20 #[must_use]
21 pub fn new(
22 id: StepId,
23 state_id: StateId,
24 handler_kind: StepHandlerKind,
25 handler_config: StepHandlerConfig,
26 retry_policy: RetryPolicy,
27 timeout: Option<StepTimeout>,
28 ) -> Self {
29 Self {
30 id,
31 state_id,
32 handler_kind,
33 handler_config,
34 retry_policy,
35 timeout,
36 repeat_policy: None,
37 }
38 }
39
40 #[must_use]
41 pub fn with_repeat_policy(mut self, repeat_policy: StepRepeatPolicy) -> Self {
42 self.repeat_policy = Some(repeat_policy);
43 self
44 }
45
46 #[must_use]
47 pub fn id(&self) -> &StepId {
48 &self.id
49 }
50
51 #[must_use]
52 pub fn state_id(&self) -> &StateId {
53 &self.state_id
54 }
55
56 #[must_use]
57 pub fn handler_kind(&self) -> &StepHandlerKind {
58 &self.handler_kind
59 }
60
61 #[must_use]
62 pub fn handler_config(&self) -> &StepHandlerConfig {
63 &self.handler_config
64 }
65
66 #[must_use]
67 pub fn retry_policy(&self) -> RetryPolicy {
68 self.retry_policy
69 }
70
71 #[must_use]
72 pub fn timeout(&self) -> Option<StepTimeout> {
73 self.timeout
74 }
75
76 #[must_use]
77 pub fn repeat_policy(&self) -> Option<&StepRepeatPolicy> {
78 self.repeat_policy.as_ref()
79 }
80}