1use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct Plan {
9 pub id: String,
10 pub steps: Vec<PlanStep>,
11 pub status: PlanStatus,
12}
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct PlanStep {
17 pub id: String,
18 pub description: String,
19 pub status: StepStatus,
20}
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
24pub enum PlanStatus {
25 Pending,
26 InProgress,
27 Completed,
28 Failed,
29}
30
31#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
33pub enum StepStatus {
34 Pending,
35 InProgress,
36 Completed,
37 Skipped,
38 Failed,
39}
40
41impl Plan {
42 pub fn new(id: String) -> Self {
43 Self {
44 id,
45 steps: Vec::new(),
46 status: PlanStatus::Pending,
47 }
48 }
49
50 pub fn add_step(&mut self, description: &str) -> &PlanStep {
51 let step = PlanStep {
52 id: uuid::Uuid::new_v4().to_string(),
53 description: description.to_string(),
54 status: StepStatus::Pending,
55 };
56
57 self.steps.push(step);
58 self.steps.last().unwrap()
59 }
60}