made-core 0.1.6

Domain core of MADE: entities, value objects, events, ports. No IO.
Documentation
use serde::{Deserialize, Serialize};

use super::{StepId, StepStatus};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum GuardCondition {
    Always,
    AllStepsCompleted,
    StepStatus { step_id: StepId, status: StepStatus },
    HumanApproval,
}

impl GuardCondition {
    #[must_use]
    pub fn referenced_step_id(&self) -> Option<&StepId> {
        match self {
            Self::StepStatus { step_id, .. } => Some(step_id),
            Self::Always | Self::AllStepsCompleted | Self::HumanApproval => None,
        }
    }
}