1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
3#[serde(rename_all = "lowercase")]
4pub enum StatusPhase {
5 Pending,
7 Running,
9 Waiting,
11 Suspended,
13 Cancelled,
15 Faulted,
17 Completed,
19}
20
21impl StatusPhase {
22 pub fn as_str(&self) -> &'static str {
24 match self {
25 StatusPhase::Pending => "pending",
26 StatusPhase::Running => "running",
27 StatusPhase::Waiting => "waiting",
28 StatusPhase::Suspended => "suspended",
29 StatusPhase::Cancelled => "cancelled",
30 StatusPhase::Faulted => "faulted",
31 StatusPhase::Completed => "completed",
32 }
33 }
34}
35
36impl std::fmt::Display for StatusPhase {
37 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
38 write!(f, "{}", self.as_str())
39 }
40}
41
42#[derive(Debug, Clone, PartialEq)]
44pub struct StatusPhaseLog {
45 pub timestamp: i64,
47 pub status: StatusPhase,
49}
50
51impl StatusPhaseLog {
52 pub fn new(status: StatusPhase) -> Self {
54 Self {
55 timestamp: chrono::Utc::now().timestamp_millis(),
56 status,
57 }
58 }
59}