artifactize_core/project/status/
states.rs1use crate::graph::{ArtifactStatus, EvalStatus};
3use serde::Serialize;
4use std::fmt;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize)]
8#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
9pub enum ArtifactCondition {
10 Basis,
11 Blocked,
12 Error,
13 Incomplete,
14 Pass,
15 Red,
16 Stale,
17 Unreviewed,
18 WaitDependency,
19}
20impl From<ArtifactStatus> for ArtifactCondition {
21 fn from(status: ArtifactStatus) -> Self {
22 match status {
23 ArtifactStatus::Basis => Self::Basis,
24 ArtifactStatus::Green => Self::Pass,
25 ArtifactStatus::Incomplete => Self::Incomplete,
26 ArtifactStatus::Error => Self::Error,
27 ArtifactStatus::Red => Self::Red,
28 ArtifactStatus::Blocked => Self::Blocked,
29 ArtifactStatus::Wait => Self::WaitDependency,
30 ArtifactStatus::Stale => Self::Stale,
31 ArtifactStatus::Unreviewed => Self::Unreviewed,
32 }
33 }
34}
35impl fmt::Display for ArtifactCondition {
36 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
37 formatter.write_str(match self {
38 Self::Basis => "BASIS",
39 Self::Blocked => "BLOCKED",
40 Self::Error => "ERROR",
41 Self::Incomplete => "INCOMPLETE",
42 Self::Pass => "PASS",
43 Self::Red => "RED",
44 Self::Stale => "STALE",
45 Self::Unreviewed => "UNREVIEWED",
46 Self::WaitDependency => "WAIT_DEPENDENCY",
47 })
48 }
49}
50
51#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize)]
52#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
53pub enum EvalCondition {
54 Blocked,
55 Error,
56 Pass,
57 Red,
58 Stale,
59 Unreviewed,
60 WaitDependency,
61 WaitingHuman,
62}
63impl From<EvalStatus> for EvalCondition {
64 fn from(status: EvalStatus) -> Self {
65 match status {
66 EvalStatus::Green => Self::Pass,
67 EvalStatus::Red => Self::Red,
68 EvalStatus::Error => Self::Error,
69 EvalStatus::Stale => Self::Stale,
70 EvalStatus::Unreviewed => Self::Unreviewed,
71 EvalStatus::Wait => Self::WaitDependency,
72 EvalStatus::Blocked => Self::Blocked,
73 }
74 }
75}
76impl fmt::Display for EvalCondition {
77 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
78 formatter.write_str(match self {
79 Self::Blocked => "BLOCKED",
80 Self::Error => "ERROR",
81 Self::Pass => "PASS",
82 Self::Red => "RED",
83 Self::Stale => "STALE",
84 Self::Unreviewed => "UNREVIEWED",
85 Self::WaitDependency => "WAIT_DEPENDENCY",
86 Self::WaitingHuman => "WAITING_HUMAN",
87 })
88 }
89}
90
91#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
92#[serde(rename_all = "lowercase")]
93pub enum VerifyAction {
94 Execute,
95 Derive,
96 Reuse,
97 Wait,
98 Blocked,
99}
100impl fmt::Display for VerifyAction {
101 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
102 formatter.write_str(match self {
103 Self::Execute => "execute",
104 Self::Derive => "derive",
105 Self::Reuse => "reuse",
106 Self::Wait => "wait",
107 Self::Blocked => "blocked",
108 })
109 }
110}