merman_core/diagrams/flowchart/
model.rs1use indexmap::IndexMap;
2use rustc_hash::FxHashMap;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct FlowchartV2Model {
7 #[serde(default, rename = "accDescr")]
8 pub acc_descr: Option<String>,
9 #[serde(default, rename = "accTitle")]
10 pub acc_title: Option<String>,
11 #[serde(default, rename = "classDefs")]
12 pub class_defs: IndexMap<String, Vec<String>>,
13 #[serde(default)]
14 pub direction: Option<String>,
15 #[serde(default, rename = "edgeDefaults")]
16 pub edge_defaults: Option<FlowEdgeDefaults>,
17 #[serde(default, rename = "vertexCalls")]
18 pub vertex_calls: Vec<String>,
19 pub nodes: Vec<FlowNode>,
20 pub edges: Vec<FlowEdge>,
21 #[serde(default)]
22 pub subgraphs: Vec<FlowSubgraph>,
23 #[serde(default)]
24 pub tooltips: FxHashMap<String, String>,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct FlowEdgeDefaults {
29 #[serde(default)]
30 pub interpolate: Option<String>,
31 #[serde(default)]
32 pub style: Vec<String>,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct FlowNode {
37 pub id: String,
38 pub label: Option<String>,
39 #[serde(default, rename = "labelType")]
40 pub label_type: Option<String>,
41 #[serde(rename = "layoutShape")]
42 pub layout_shape: Option<String>,
43 #[serde(default)]
44 pub icon: Option<String>,
45 #[serde(default)]
46 pub form: Option<String>,
47 #[serde(default)]
48 pub pos: Option<String>,
49 #[serde(default)]
50 pub img: Option<String>,
51 #[serde(default)]
52 pub constraint: Option<String>,
53 #[serde(default, rename = "assetWidth")]
54 pub asset_width: Option<f64>,
55 #[serde(default, rename = "assetHeight")]
56 pub asset_height: Option<f64>,
57 #[serde(default)]
58 pub classes: Vec<String>,
59 #[serde(default)]
60 pub styles: Vec<String>,
61 #[serde(default)]
62 pub link: Option<String>,
63 #[serde(default, rename = "linkTarget")]
64 pub link_target: Option<String>,
65 #[serde(default, rename = "haveCallback")]
66 pub have_callback: bool,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct FlowEdge {
71 pub id: String,
72 pub from: String,
73 pub to: String,
74 pub label: Option<String>,
75 #[serde(default, rename = "labelType")]
76 pub label_type: Option<String>,
77 #[serde(default, rename = "type")]
78 pub edge_type: Option<String>,
79 #[serde(default)]
80 pub stroke: Option<String>,
81 #[serde(default)]
82 pub interpolate: Option<String>,
83 #[serde(default)]
84 pub classes: Vec<String>,
85 #[serde(default)]
86 pub style: Vec<String>,
87 #[serde(default)]
88 pub animate: Option<bool>,
89 #[serde(default)]
90 pub animation: Option<String>,
91 pub length: usize,
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize)]
95pub struct FlowSubgraph {
96 pub id: String,
97 pub title: String,
98 pub dir: Option<String>,
99 #[serde(default, rename = "labelType")]
100 pub label_type: Option<String>,
101 #[serde(default)]
102 pub classes: Vec<String>,
103 #[serde(default)]
104 pub styles: Vec<String>,
105 pub nodes: Vec<String>,
106}
107
108#[derive(Debug, Clone)]
109pub(crate) struct Node {
110 pub id: String,
111 pub label: Option<String>,
112 pub label_type: TitleKind,
113 pub shape: Option<String>,
114 pub shape_data: Option<String>,
115 pub icon: Option<String>,
116 pub form: Option<String>,
117 pub pos: Option<String>,
118 pub img: Option<String>,
119 pub constraint: Option<String>,
120 pub asset_width: Option<f64>,
121 pub asset_height: Option<f64>,
122 pub styles: Vec<String>,
123 pub classes: Vec<String>,
124 pub link: Option<String>,
125 pub link_target: Option<String>,
126 pub have_callback: bool,
127}
128
129#[derive(Debug, Clone)]
130pub(crate) struct Edge {
131 pub from: String,
132 pub to: String,
133 pub id: Option<String>,
134 pub link: LinkToken,
135 pub label: Option<String>,
136 pub label_type: TitleKind,
137 pub style: Vec<String>,
138 pub classes: Vec<String>,
139 pub interpolate: Option<String>,
140 pub is_user_defined_id: bool,
141 pub animate: Option<bool>,
142 pub animation: Option<String>,
143}
144
145#[derive(Debug, Clone)]
146pub(crate) struct LinkToken {
147 pub end: String,
148 pub edge_type: String,
149 pub stroke: String,
150 pub length: usize,
151}
152
153#[derive(Debug, Clone)]
154pub(crate) struct EdgeDefaults {
155 pub style: Vec<String>,
156 pub interpolate: Option<String>,
157}
158
159#[allow(dead_code)]
160#[derive(Debug, Clone, PartialEq, Eq)]
161pub(crate) enum TitleKind {
162 Text,
163 String,
164 Markdown,
165}
166
167#[derive(Debug, Clone)]
168pub(crate) struct LabeledText {
169 pub text: String,
170 pub kind: TitleKind,
171}
172
173#[derive(Debug, Clone, PartialEq, Eq)]
174pub(crate) struct SubgraphHeader {
175 pub raw_id: String,
176 pub raw_title: String,
177 pub title_kind: TitleKind,
178 pub id_equals_title: bool,
179}
180
181impl Default for SubgraphHeader {
182 fn default() -> Self {
183 Self {
184 raw_id: String::new(),
185 raw_title: String::new(),
186 title_kind: TitleKind::Text,
187 id_equals_title: true,
188 }
189 }
190}