use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Plan {
pub id: String,
pub steps: Vec<PlanStep>,
pub status: PlanStatus,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PlanStep {
pub id: String,
pub description: String,
pub status: StepStatus,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum PlanStatus {
Pending,
InProgress,
Completed,
Failed,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum StepStatus {
Pending,
InProgress,
Completed,
Skipped,
Failed,
}
impl Plan {
pub fn new(id: String) -> Self {
Self {
id,
steps: Vec::new(),
status: PlanStatus::Pending,
}
}
pub fn add_step(&mut self, description: &str) -> &PlanStep {
let step = PlanStep {
id: uuid::Uuid::new_v4().to_string(),
description: description.to_string(),
status: StepStatus::Pending,
};
self.steps.push(step);
self.steps.last().unwrap()
}
}