-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschema.rs
146 lines (107 loc) · 2.79 KB
/
schema.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//! Generated from JSON schema of [smcat-ast]
//! using https://quicktype.io with some fixes
//! [smcat-ast]: https://github.com/sverweij/state-machine-cat/blob/develop/src/parse/smcat-ast.schema.json
#![allow(dead_code)]
use serde::Serialize;
use serde_with::skip_serializing_none;
// TODO: is it necessary to watch smcat-ast.schema.json then generate this automatically on each release 🤔
#[skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize)]
pub struct State {
#[serde(rename = "actions")]
pub actions: Option<Vec<ActionType>>,
#[serde(rename = "active")]
pub active: Option<bool>,
#[serde(rename = "color")]
pub color: Option<String>,
#[serde(rename = "isComposite")]
pub is_composite: Option<bool>,
#[serde(rename = "label")]
pub label: Option<String>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "note")]
pub note: Option<Vec<String>>,
#[serde(rename = "statemachine")]
pub statemachine: Option<Coordinate>,
#[serde(rename = "type")]
pub state_type: StateType,
#[serde(rename = "typeExplicitlySet")]
pub type_explicitly_set: Option<bool>,
}
#[skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize)]
pub struct Coordinate {
#[serde(rename = "states")]
pub states: Vec<State>,
#[serde(rename = "transitions")]
pub transitions: Option<Vec<Transition>>,
}
#[derive(Debug, Clone, Serialize)]
pub struct ActionType {
#[serde(rename = "body")]
pub body: String,
#[serde(rename = "type")]
pub action_type_type: ActionTypeType,
}
#[skip_serializing_none]
#[derive(Debug, Default, Clone, Serialize)]
pub struct Transition {
#[serde(rename = "action")]
pub action: Option<String>,
#[serde(rename = "color")]
pub color: Option<String>,
#[serde(rename = "cond")]
pub cond: Option<String>,
#[serde(rename = "event")]
pub event: Option<String>,
#[serde(rename = "from")]
pub from: String,
#[serde(rename = "label")]
pub label: Option<String>,
#[serde(rename = "note")]
pub note: Option<Vec<String>>,
#[serde(rename = "to")]
pub to: String,
}
#[derive(Debug, Clone, Serialize)]
pub enum ActionTypeType {
#[serde(rename = "activity")]
Activity,
#[serde(rename = "entry")]
Entry,
#[serde(rename = "exit")]
Exit,
}
impl Default for StateType {
fn default() -> Self {
StateType::Regular
}
}
#[derive(Debug, Clone, Serialize)]
pub enum StateType {
#[serde(rename = "choice")]
Choice,
#[serde(rename = "deephistory")]
Deephistory,
#[serde(rename = "final")]
Final,
#[serde(rename = "fork")]
Fork,
#[serde(rename = "forkjoin")]
Forkjoin,
#[serde(rename = "history")]
History,
#[serde(rename = "initial")]
Initial,
#[serde(rename = "join")]
Join,
#[serde(rename = "junction")]
Junction,
#[serde(rename = "parallel")]
Parallel,
#[serde(rename = "regular")]
Regular,
#[serde(rename = "terminate")]
Terminate,
}