dot_ix_model 0.10.0

Model for the `dot_ix` diagramming application.
Documentation
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
use serde::{Deserialize, Serialize};

pub use self::{
    cluster_margin::ClusterMargin, edge_constraints::EdgeConstraints, edge_dir::EdgeDir,
    edge_dirs::EdgeDirs, edge_minlens::EdgeMinlens, fixed_size::FixedSize, margin::Margin,
    margins::Margins, node_heights::NodeHeights, node_margin::NodeMargin, node_widths::NodeWidths,
    pack_mode::PackMode, pack_mode_flag::PackModeFlag, splines::Splines,
};

mod cluster_margin;
mod edge_constraints;
mod edge_dir;
mod edge_dirs;
mod edge_minlens;
mod fixed_size;
mod margin;
mod margins;
mod node_heights;
mod node_margin;
mod node_widths;
mod pack_mode;
mod pack_mode_flag;
mod splines;

/// Additional attributes specifically for GraphViz.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[serde(default)]
pub struct GraphvizAttrs {
    /// Minimum space between two adjacent nodes in the same rank, in
    /// inches. Also controls the spacing between multiple edges between the
    /// same pair of nodes.
    ///
    /// Defaults to `0.25`. Minimum `0.02`.
    ///
    /// See [`nodesep`].
    ///
    /// [`nodesep`]: https://graphviz.org/docs/attrs/nodesep/
    pub nodesep: f64,
    /// The desired separation between nodes of different ranks, in inches. See
    /// [`ranksep`].
    ///
    /// Defaults to `0.25`. Minimum `0.02`.
    ///
    /// This does not support the `equally` string (yet). I'm not sure if it is
    /// used.
    ///
    /// [`ranksep`]: https://graphviz.org/docs/attrs/ranksep/
    pub ranksep: f64,
    /// How to render edge lines. See [`splines`].
    ///
    /// [`splines`]: https://graphviz.org/docs/attrs/splines/
    pub splines: Splines,
    /// The default [`constraint`] value for edges, defaults to `true`.
    ///
    /// [`constraint`]: https://graphviz.org/docs/attrs/constraint/
    pub edge_constraint_default: bool,
    /// Each edge's [`constraint`].
    ///
    /// [`constraint`]: https://graphviz.org/docs/attrs/constraint/
    pub edge_constraints: EdgeConstraints,
    /// The default [`dir`] value for edges, defaults to [`EdgeDir::Forward`].
    ///
    /// [`dir`]: https://graphviz.org/docs/attrs/dir/
    pub edge_dir_default: EdgeDir,
    /// Each edge's [`dir`].
    ///
    /// [`dir`]: https://graphviz.org/docs/attrs/dir/
    pub edge_dirs: EdgeDirs,
    /// The default [`minlen`] for edges, defaults to `1`.
    ///
    /// [`minlen`]: https://graphviz.org/docs/attrs/minlen/
    pub edge_minlen_default: u32,
    /// Each edge's [`minlen`].
    ///
    /// [`minlen`]: https://graphviz.org/docs/attrs/minlen/
    pub edge_minlens: EdgeMinlens,
    /// The default value for each node's [`margin`], defaults to `0.11,0.055`.
    ///
    /// May be a single float, or two floats separated by a comma.
    ///
    /// [`margin`]: https://graphviz.org/docs/attrs/margin/
    pub margin_cluster_default: ClusterMargin,
    /// The default value for each cluster's [`margin`], defaults to `8.0`.
    ///
    /// May be a single float, or two floats separated by a comma.
    ///
    /// [`margin`]: https://graphviz.org/docs/attrs/margin/
    pub margin_node_default: NodeMargin,
    /// Each node or cluster's [`margin`].
    ///
    /// May be a single float, or two floats separated by a comma.
    ///
    /// [`margin`]: https://graphviz.org/docs/attrs/margin/
    pub margins: Margins,
    /// Minimum / initial [`width`] for nodes, defaults to `0.3`.
    ///
    /// If `fixedsize` is true, this will be the exact / maximum width for
    /// nodes.
    ///
    /// [`width`]: https://graphviz.org/docs/attrs/width/
    pub node_width_default: f64,
    /// Each node's [`width`].
    ///
    /// If `fixedsize` is true, this will be the exact / maximum width for
    /// nodes.
    ///
    /// [`width`]: https://graphviz.org/docs/attrs/width/
    pub node_widths: NodeWidths,
    /// Minimum / initial [`height`] for nodes, defaults to `0.1`.
    ///
    /// If `fixedsize` is true, this will be the exact / maximum height for
    /// nodes.
    ///
    /// [`height`]: https://graphviz.org/docs/attrs/height/
    pub node_height_default: f64,
    /// Each node's [`height`].
    ///
    /// If `fixedsize` is true, this will be the exact / maximum height for
    /// nodes.
    ///
    /// [`height`]: https://graphviz.org/docs/attrs/height/
    pub node_heights: NodeHeights,
    /// Whether a node's `width` and `height` are fixed dimensions.
    ///
    /// See [`fixedsize`].
    ///
    /// [`fixedsize`]: https://graphviz.org/docs/attrs/fixedsize/
    pub fixed_size: FixedSize,
    /// How closely to pack together graph components.
    pub pack_mode: PackMode,
}

impl GraphvizAttrs {
    /// Returns a new `GraphvizOpts` map.
    pub fn new() -> Self {
        Self::default()
    }

    /// Sets the minimum space between two adjacent nodes in the same rank, in
    /// inches. Also controls the spacing between multiple edges between the
    /// same pair of nodes.
    ///
    /// Defaults to `0.25`. Minimum `0.02`.
    ///
    /// See [`nodesep`].
    ///
    /// [`nodesep`]: https://graphviz.org/docs/attrs/nodesep/
    pub fn with_nodesep(mut self, nodesep: f64) -> Self {
        self.nodesep = nodesep;
        self
    }

    /// Sets the desired separation between nodes of different ranks, in inches.
    /// See [`ranksep`].
    ///
    /// Defaults to `0.25`. Minimum `0.02`.
    ///
    /// This does not support the `equally` string (yet). I'm not sure if it is
    /// used.
    ///
    /// [`ranksep`]: https://graphviz.org/docs/attrs/ranksep/
    pub fn with_ranksep(mut self, ranksep: f64) -> Self {
        self.ranksep = ranksep;
        self
    }

    /// Sets how to render edge lines. See [`splines`].
    ///
    /// [`splines`]: https://graphviz.org/docs/attrs/splines/
    pub fn with_splines(mut self, splines: Splines) -> Self {
        self.splines = splines;
        self
    }

    /// Sets the default [`constraint`] value for edges.
    ///
    /// [`constraint`]: https://graphviz.org/docs/attrs/constraint/
    pub fn with_edge_constraint_default(mut self, edge_constraint_default: bool) -> Self {
        self.edge_constraint_default = edge_constraint_default;
        self
    }

    /// Sets the map of edge [`constraint`]s.
    ///
    /// [`constraint`]: https://graphviz.org/docs/attrs/constraint/
    pub fn with_edge_constraints(mut self, edge_constraints: EdgeConstraints) -> Self {
        self.edge_constraints = edge_constraints;
        self
    }

    /// Sets the default [`dir`] value for edges.
    ///
    /// [`dir`]: https://graphviz.org/docs/attrs/dir/
    pub fn with_edge_dir_default(mut self, edge_dir_default: EdgeDir) -> Self {
        self.edge_dir_default = edge_dir_default;
        self
    }

    /// Sets the map of edge [`dir`]s.
    ///
    /// [`dir`]: https://graphviz.org/docs/attrs/dir/
    pub fn with_edge_dirs(mut self, edge_dirs: EdgeDirs) -> Self {
        self.edge_dirs = edge_dirs;
        self
    }

    /// Sets the default [`minlen`] value for edges.
    ///
    /// [`minlen`]: https://graphviz.org/docs/attrs/minlen/
    pub fn with_edge_minlen_default(mut self, edge_minlen_default: u32) -> Self {
        self.edge_minlen_default = edge_minlen_default;
        self
    }

    /// Sets the map of edge [`minlen`]s.
    ///
    /// [`minlen`]: https://graphviz.org/docs/attrs/minlen/
    pub fn with_edge_minlens(mut self, edge_minlens: EdgeMinlens) -> Self {
        self.edge_minlens = edge_minlens;
        self
    }

    /// Sets the default value for each node's [`margin`], defaults to
    /// `0.11,0.055`.
    ///
    /// May be a single float, or two floats separated by a comma.
    ///
    /// [`margin`]: https://graphviz.org/docs/attrs/margin/
    pub fn with_margin_cluster_default(mut self, margin_cluster_default: ClusterMargin) -> Self {
        self.margin_cluster_default = margin_cluster_default;
        self
    }

    /// Sets the default value for each cluster's [`margin`], defaults to `8.0`.
    ///
    /// May be a single float, or two floats separated by a comma.
    ///
    /// [`margin`]: https://graphviz.org/docs/attrs/margin/
    pub fn with_margin_node_default(mut self, margin_node_default: NodeMargin) -> Self {
        self.margin_node_default = margin_node_default;
        self
    }

    /// Sets each node or cluster's [`margin`].
    ///
    /// May be a single float, or two floats separated by a comma.
    ///
    /// [`margin`]: https://graphviz.org/docs/attrs/margin/
    pub fn with_margins(mut self, margins: Margins) -> Self {
        self.margins = margins;
        self
    }

    /// Sets the minimum / initial [`width`] for nodes, defaults to `0.3`.
    ///
    /// If `fixedsize` is true, this will be the exact / maximum width for
    /// nodes.
    ///
    /// [`width`]: https://graphviz.org/docs/attrs/width/
    pub fn with_node_width_default(mut self, node_width_default: f64) -> Self {
        self.node_width_default = node_width_default;
        self
    }

    /// Sets each node's [`width`].
    ///
    /// If `fixedsize` is true, this will be the exact / maximum width for
    /// nodes.
    ///
    /// [`width`]: https://graphviz.org/docs/attrs/width/
    pub fn with_node_widths(mut self, node_widths: NodeWidths) -> Self {
        self.node_widths = node_widths;
        self
    }

    /// Sets the minimum / initial [`height`] for nodes, defaults to `0.1`.
    ///
    /// If `fixedsize` is true, this will be the exact / maximum height for
    /// nodes.
    ///
    /// [`height`]: https://graphviz.org/docs/attrs/height/
    pub fn with_node_height_default(mut self, node_height_default: f64) -> Self {
        self.node_height_default = node_height_default;
        self
    }

    /// Sets each node's [`height`].
    ///
    /// If `fixedsize` is true, this will be the exact / maximum height for
    /// nodes.
    ///
    /// [`height`]: https://graphviz.org/docs/attrs/height/
    pub fn with_node_heights(mut self, node_heights: NodeHeights) -> Self {
        self.node_heights = node_heights;
        self
    }

    /// Sets whether a node's `width` and `height` are fixed dimensions.
    ///
    /// See [`fixedsize`].
    ///
    /// [`fixedsize`]: https://graphviz.org/docs/attrs/fixedsize/
    pub fn with_fixed_size(mut self, fixed_size: FixedSize) -> Self {
        self.fixed_size = fixed_size;
        self
    }

    /// Returns the minimum space between two adjacent nodes in the same rank,
    /// in inches. Also controls the spacing between multiple edges between
    /// the same pair of nodes.
    ///
    /// Defaults to `0.25`. Minimum `0.02`.
    ///
    /// See [`nodesep`].
    ///
    /// [`nodesep`]: https://graphviz.org/docs/attrs/nodesep/
    pub fn nodesep(&self) -> f64 {
        self.nodesep
    }

    /// Returns the desired separation between nodes of different ranks, in
    /// inches. See [`ranksep`].
    ///
    /// Defaults to `0.25`. Minimum `0.02`.
    ///
    /// [`ranksep`]: https://graphviz.org/docs/attrs/ranksep/
    pub fn ranksep(&self) -> f64 {
        self.ranksep
    }

    /// Returns how to render edge lines. See [`splines`].
    ///
    /// [`splines`]: https://graphviz.org/docs/attrs/splines/
    pub fn splines(&self) -> Splines {
        self.splines
    }

    /// Returns the default [`constraint`] value for edges.
    ///
    /// [`constraint`]: https://graphviz.org/docs/attrs/constraint/
    pub fn edge_constraint_default(&self) -> bool {
        self.edge_constraint_default
    }

    /// Returns the map of edge [`constraint`]s.
    ///
    /// [`constraint`]: https://graphviz.org/docs/attrs/constraint/
    pub fn edge_constraints(&self) -> &EdgeConstraints {
        &self.edge_constraints
    }

    /// Returns the default [`dir`] value for edges.
    ///
    /// [`dir`]: https://graphviz.org/docs/attrs/dir/
    pub fn edge_dir_default(&self) -> EdgeDir {
        self.edge_dir_default
    }

    /// Returns the map of edge [`dir`]s.
    ///
    /// [`dir`]: https://graphviz.org/docs/attrs/dir/
    pub fn edge_dirs(&self) -> &EdgeDirs {
        &self.edge_dirs
    }

    /// Returns the default [`minlen`] value for edges.
    ///
    /// [`minlen`]: https://graphviz.org/docs/attrs/minlen/
    pub fn edge_minlen_default(&self) -> u32 {
        self.edge_minlen_default
    }

    /// Returns the map of edge [`minlen`]s.
    ///
    /// [`minlen`]: https://graphviz.org/docs/attrs/minlen/
    pub fn edge_minlens(&self) -> &EdgeMinlens {
        &self.edge_minlens
    }

    /// Returns the default value for each node's [`margin`].
    ///
    /// May be a single float, or two floats separated by a comma.
    ///
    /// [`margin`]: https://graphviz.org/docs/attrs/margin/
    pub fn margin_cluster_default(&self) -> ClusterMargin {
        self.margin_cluster_default
    }

    /// Returns the default value for each cluster's [`margin`].
    ///
    /// May be a single float, or two floats separated by a comma.
    ///
    /// [`margin`]: https://graphviz.org/docs/attrs/margin/
    pub fn margin_node_default(&self) -> NodeMargin {
        self.margin_node_default
    }

    /// Returns each node or cluster's [`margin`].
    ///
    /// May be a single float, or two floats separated by a comma.
    ///
    /// [`margin`]: https://graphviz.org/docs/attrs/margin/
    pub fn margins(&self) -> &Margins {
        &self.margins
    }

    /// Returns the minimum / initial [`width`] for nodes.
    ///
    /// If `fixedsize` is true, this will be the exact / maximum width for
    /// nodes.
    ///
    /// [`width`]: https://graphviz.org/docs/attrs/width/
    pub fn node_width_default(&self) -> f64 {
        self.node_width_default
    }

    /// Returns each node's [`width`].
    ///
    /// If `fixedsize` is true, this will be the exact / maximum width for
    /// nodes.
    ///
    /// [`width`]: https://graphviz.org/docs/attrs/width/
    pub fn node_widths(&self) -> &NodeWidths {
        &self.node_widths
    }

    /// Returns the minimum / initial [`height`] for nodes.
    ///
    /// If `fixedsize` is true, this will be the exact / maximum height for
    /// nodes.
    ///
    /// [`height`]: https://graphviz.org/docs/attrs/height/
    pub fn node_height_default(&self) -> f64 {
        self.node_height_default
    }

    /// Returns each node's [`height`].
    ///
    /// If `fixedsize` is true, this will be the exact / maximum height for
    /// nodes.
    ///
    /// [`height`]: https://graphviz.org/docs/attrs/height/
    pub fn node_heights(&self) -> &NodeHeights {
        &self.node_heights
    }

    /// Returns whether a node's `width` and `height` are fixed dimensions.
    ///
    /// See [`fixedsize`].
    ///
    /// [`fixedsize`]: https://graphviz.org/docs/attrs/fixedsize/
    pub fn fixed_size(&self) -> FixedSize {
        self.fixed_size
    }
}

impl Default for GraphvizAttrs {
    fn default() -> Self {
        Self {
            nodesep: 0.25,
            ranksep: 0.25,
            splines: Splines::default(),
            edge_constraint_default: true,
            edge_constraints: EdgeConstraints::default(),
            edge_dir_default: EdgeDir::default(),
            edge_dirs: EdgeDirs::default(),
            edge_minlen_default: 2,
            edge_minlens: EdgeMinlens::default(),
            margin_cluster_default: ClusterMargin::default(),
            margin_node_default: NodeMargin::default(),
            margins: Margins::default(),
            node_width_default: 0.3,
            node_widths: NodeWidths::default(),
            node_height_default: 0.1,
            node_heights: NodeHeights::default(),
            fixed_size: FixedSize::default(),
            pack_mode: PackMode::default(),
        }
    }
}