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
use std::{fmt, fmt::Display, str::FromStr};
use serde::{Deserialize, Serialize};
/// How to render edge lines. See [`splines`].
///
/// [`splines`]: https://graphviz.org/docs/attrs/splines/
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum Splines {
/// Edges should be drawn using the layout engine's default.
///
/// For `dot`, this is equivalent to `Spline`.
#[default]
Unset,
/// Edges should not be drawn.
None,
/// Edges should be drawn using straight lines.
Line,
/// Edges should be drawn with a few straight lines.
Polyline,
/// Edges should be drawn with a curved line, with a single curve.
Curved,
/// Edges should be drawn with lines that only bend with 90 degree angles.
Ortho,
/// Edges should be drawn with a curved line that can curve multiple times.
Spline,
}
impl FromStr for Splines {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"" => Ok(Self::Unset),
"none" => Ok(Self::None),
"line" => Ok(Self::Line),
"polyline" => Ok(Self::Polyline),
"curved" => Ok(Self::Curved),
"ortho" => Ok(Self::Ortho),
"spline" => Ok(Self::Spline),
_ => Err(format!(
"Unable to map `{s}` to a `Splines`. Valid strings are: \
\"\", \"none\", \"line\", \"polyline\", \"curved\", \"ortho\", \"spline\"."
)),
}
}
}
impl Display for Splines {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Splines::Unset => "".fmt(f),
Splines::None => "none".fmt(f),
Splines::Line => "line".fmt(f),
Splines::Polyline => "polyline".fmt(f),
Splines::Curved => "curved".fmt(f),
Splines::Ortho => "ortho".fmt(f),
Splines::Spline => "spline".fmt(f),
}
}
}