1use std::fmt::Display;
2
3use chrono::{DateTime, Utc};
4
5use crate::action::Asset;
6use crate::case::CaseId;
7use crate::collection::TailDropVec;
8use crate::value::Value;
9
10pub trait StepId: Sync + Send + Display {
11 fn step(&self) -> &str;
12
13 fn case_id(&self) -> &dyn CaseId;
14}
15
16pub enum ActionState {
17 Ok(Asset),
18 Err(crate::action::Error),
19}
20
21impl ActionState {
22 pub fn is_ok(&self) -> bool {
23 match self {
24 ActionState::Ok(_) => true,
25 _ => false,
26 }
27 }
28
29 pub fn is_err(&self) -> bool {
30 match self {
31 ActionState::Err(_) => true,
32 _ => false,
33 }
34 }
35}
36
37pub trait ActionAsset: Sync + Send {
38 fn id(&self) -> &str;
39
40 fn start(&self) -> DateTime<Utc>;
41
42 fn end(&self) -> DateTime<Utc>;
43
44 fn explain(&self) -> &Value;
45
46 fn state(&self) -> &ActionState;
47}
48
49
50pub enum StepState {
51 Ok(TailDropVec<Box<dyn ActionAsset>>),
52 Fail(TailDropVec<Box<dyn ActionAsset>>),
53}
54
55impl StepState {
56 pub fn is_ok(&self) -> bool {
57 match self {
58 StepState::Ok(_) => true,
59 _ => false,
60 }
61 }
62
63 pub fn is_fail(&self) -> bool {
64 match self {
65 StepState::Fail(_) => true,
66 _ => false,
67 }
68 }
69}
70
71pub trait StepAsset: Sync + Send {
72 fn id(&self) -> &dyn StepId;
73
74 fn start(&self) -> DateTime<Utc>;
75
76 fn end(&self) -> DateTime<Utc>;
77
78 fn state(&self) -> &StepState;
79}