summaryrefslogtreecommitdiff
path: root/src/attributes/compass_point.rs
diff options
context:
space:
mode:
authorseancarroll <seanc28@gmail.com>2021-01-06 21:11:57 -0600
committerseancarroll <seanc28@gmail.com>2021-01-06 21:11:57 -0600
commitc95ff86e2c8fbdd8e0cf6550aadc7ffc676dcc16 (patch)
treecfc0db9248e14f2ea675cf3b6dc67bf7243d1701 /src/attributes/compass_point.rs
parent0c8eb45449e578cae1f27e93df3f9cc92ba68219 (diff)
downloaddotavious-c95ff86e2c8fbdd8e0cf6550aadc7ffc676dcc16.zip
trying to organize files and use declarations
Diffstat (limited to 'src/attributes/compass_point.rs')
-rw-r--r--src/attributes/compass_point.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/attributes/compass_point.rs b/src/attributes/compass_point.rs
new file mode 100644
index 0000000..3ebb250
--- /dev/null
+++ b/src/attributes/compass_point.rs
@@ -0,0 +1,41 @@
+use crate::dot::DotString;
+use std::borrow::Cow;
+
+// TODO: not sure we need this enum but should support setting nodeport either via
+// headport / tailport attributes e.g. a -> b [tailport=se]
+// or via edge declaration using the syntax node name:port_name e.g. a -> b:se
+// aka compass
+#[derive(Clone, PartialEq, Eq, Debug)]
+pub enum CompassPoint {
+ N,
+ NE,
+ E,
+ SE,
+ S,
+ SW,
+ W,
+ NW,
+ C,
+ // TODO: none might not be a good name
+ // The compass point "_" specifies that an appropriate side of the port adjacent to the exterior
+ // of the node should be used, if such exists. Otherwise, the center is used.
+ // If no compass point is used with a portname, the default value is "_".
+ None,
+}
+
+impl<'a> DotString<'a> for CompassPoint {
+ fn dot_string(&self) -> Cow<'a, str> {
+ match self {
+ CompassPoint::N => "n".into(),
+ CompassPoint::NE => "ne".into(),
+ CompassPoint::E => "e".into(),
+ CompassPoint::SE => "se".into(),
+ CompassPoint::S => "s".into(),
+ CompassPoint::SW => "sw".into(),
+ CompassPoint::W => "w".into(),
+ CompassPoint::NW => "nw".into(),
+ CompassPoint::C => "c".into(),
+ CompassPoint::None => "_".into(),
+ }
+ }
+}