echo_library/types/
task.rs

1use super::*;
2
3#[derive(Debug, PartialEq, Eq, ProvidesStaticType, Allocative, Clone, Deserialize, Serialize)]
4pub enum Operation {
5    Normal,
6    Concat,
7    Combine,
8    Map(String),
9}
10
11impl Operation {
12    pub fn is_map(&self) -> bool {
13        matches!(self, Self::Map(_))
14    }
15
16    pub fn is_combine(&self) -> bool {
17        matches!(self, Self::Combine)
18    }
19}
20
21impl Default for Operation {
22    fn default() -> Operation {
23        Self::Normal
24    }
25}
26
27#[derive(
28    Debug, Default, PartialEq, Eq, Allocative, ProvidesStaticType, Clone, Deserialize, Serialize,
29)]
30pub struct Depend {
31    pub task_name: String,
32    pub cur_field: String,
33    pub prev_field: String,
34}
35
36#[derive(
37    Debug, Default, PartialEq, Eq, ProvidesStaticType, Allocative, Clone, Deserialize, Serialize,
38)]
39pub struct Task {
40    pub kind: String,
41    pub action_name: String,
42    pub input_arguments: Vec<Input>,
43    pub attributes: HashMap<String, String>,
44    #[serde(default)]
45    pub operation: Operation,
46    pub depend_on: Vec<Depend>,
47}