1use std::fmt;
6
7use oxidd_core::Tag;
8
9#[derive(Clone, Copy, PartialEq, Eq, Debug)]
11pub enum EdgeStyle {
12 #[allow(missing_docs)]
13 Solid,
14 #[allow(missing_docs)]
15 Dashed,
16 #[allow(missing_docs)]
17 Dotted,
18}
19
20impl fmt::Display for EdgeStyle {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 f.write_str(match self {
23 EdgeStyle::Solid => "solid",
24 EdgeStyle::Dashed => "dashed",
25 EdgeStyle::Dotted => "dotted",
26 })
27 }
28}
29
30#[derive(Clone, Copy, PartialEq, Eq, Debug)]
34pub struct Color(pub u8, pub u8, pub u8);
35
36impl Color {
37 #[allow(missing_docs)]
38 pub const BLACK: Self = Color(0, 0, 0);
39}
40
41impl fmt::Display for Color {
42 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43 write!(f, "#{:02X}{:02X}{:02X}", self.0, self.1, self.2)
44 }
45}
46
47pub trait DotStyle<T: Tag> {
49 fn edge_style(no: usize, tag: T) -> (EdgeStyle, bool, Color) {
63 (
64 if tag != Default::default() {
65 EdgeStyle::Dotted
66 } else if no == 1 {
67 EdgeStyle::Dashed
68 } else {
69 EdgeStyle::Solid
70 },
71 false,
72 Color::BLACK,
73 )
74 }
75}
76
77#[cfg(feature = "dot")]
78mod dot_impl;
79#[cfg(feature = "dot")]
80pub use dot_impl::dump_all;