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