From c95ff86e2c8fbdd8e0cf6550aadc7ffc676dcc16 Mon Sep 17 00:00:00 2001 From: seancarroll Date: Wed, 6 Jan 2021 21:11:57 -0600 Subject: trying to organize files and use declarations --- src/attributes/style.rs | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 src/attributes/style.rs (limited to 'src/attributes/style.rs') diff --git a/src/attributes/style.rs b/src/attributes/style.rs new file mode 100644 index 0000000..0b7fd2a --- /dev/null +++ b/src/attributes/style.rs @@ -0,0 +1,92 @@ +use crate::dot::DotString; +use std::borrow::Cow; + +pub enum NodeStyle { + Bold, + Dashed, + Diagonals, + Dotted, + Filled, + Invisible, + Rounded, + Solid, + Stripped, + Radical, + Wedged, +} + +impl<'a> DotString<'a> for NodeStyle { + fn dot_string(&self) -> Cow<'a, str> { + match self { + NodeStyle::Bold => "bold".into(), + NodeStyle::Dashed => "dashed".into(), + NodeStyle::Diagonals => "diagonals".into(), + NodeStyle::Dotted => "dotted".into(), + NodeStyle::Filled => "filled".into(), + NodeStyle::Invisible => "invisible".into(), + NodeStyle::Rounded => "rounded".into(), + NodeStyle::Solid => "solid".into(), + NodeStyle::Stripped => "stripped".into(), + NodeStyle::Radical => "radical".into(), + NodeStyle::Wedged => "wedged".into(), + } + } +} + +pub enum EdgeStyle { + Bold, + Dashed, + Dotted, + Invisible, + Solid, + Tapered, +} + +impl<'a> DotString<'a> for EdgeStyle { + fn dot_string(&self) -> Cow<'a, str> { + match self { + EdgeStyle::Bold => "bold".into(), + EdgeStyle::Dashed => "dashed".into(), + EdgeStyle::Dotted => "dotted".into(), + EdgeStyle::Invisible => "invisible".into(), + EdgeStyle::Solid => "solid".into(), + EdgeStyle::Tapered => "tapered".into(), + } + } +} + +pub enum GraphStyle { + Filled, + Radical, + Rounded, + Striped, +} + +impl<'a> DotString<'a> for GraphStyle { + fn dot_string(&self) -> Cow<'a, str> { + match self { + GraphStyle::Filled => "filled".into(), + GraphStyle::Radical => "radical".into(), + GraphStyle::Rounded => "rounded".into(), + GraphStyle::Striped => "striped".into(), + } + } +} + +// TODO: this might be a bit much to in order to avoid some duplication +// probably not worth it but is pattern is cool nonetheless +pub enum Styles { + Edge(EdgeStyle), + Node(NodeStyle), + Graph(GraphStyle), +} + +impl<'a> DotString<'a> for Styles { + fn dot_string(&self) -> Cow<'a, str> { + match self { + Styles::Edge(s) => s.dot_string(), + Styles::Node(s) => s.dot_string(), + Styles::Graph(s) => s.dot_string(), + } + } +} -- cgit v1.2.3