made_core/value_objects/ceremony/
guard_condition.rs1use serde::{Deserialize, Serialize};
2
3use super::{
4 JoinStepCount, OutputFieldGuardCondition, StepId, StepRepeatExhaustedGuardCondition, StepStatus,
5};
6
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(tag = "kind", rename_all = "snake_case")]
9pub enum GuardCondition {
10 Always,
11 AllStepsCompleted,
12 AnyStepCompleted,
13 StepsCompleted(JoinStepCount),
14 StepStatus { step_id: StepId, status: StepStatus },
15 OutputField(OutputFieldGuardCondition),
16 StepRepeatExhausted(StepRepeatExhaustedGuardCondition),
17 HumanApproval,
18}
19
20impl GuardCondition {
21 #[must_use]
22 pub fn referenced_step_id(&self) -> Option<&StepId> {
23 match self {
24 Self::StepStatus { step_id, .. } => Some(step_id),
25 Self::OutputField(condition) => Some(condition.step_id()),
26 Self::StepRepeatExhausted(condition) => Some(condition.step_id()),
27 Self::Always
28 | Self::AllStepsCompleted
29 | Self::AnyStepCompleted
30 | Self::StepsCompleted(_)
31 | Self::HumanApproval => None,
32 }
33 }
34}