#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Side {
Top,
Bottom,
Left,
Right,
}
impl Side {
pub fn parse(s: &str) -> Option<Self> {
Some(match s {
"top" => Self::Top,
"bottom" => Self::Bottom,
"left" => Self::Left,
"right" => Self::Right,
_ => return None,
})
}
pub fn index(self) -> u8 {
match self {
Side::Top => 0,
Side::Right => 1,
Side::Bottom => 2,
Side::Left => 3,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct LinkOp {
pub line: LineStyle,
pub start: LinkMarker,
pub end: LinkMarker,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LineStyle {
Solid, Dashed, Dotted, Wavy, }
impl LineStyle {
pub fn as_str(self) -> &'static str {
match self {
Self::Solid => "-",
Self::Dashed => "--",
Self::Dotted => "---",
Self::Wavy => "~",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum LinkMarker {
#[default]
None,
Arrow, Crow, Dot, Diamond, }
impl LinkMarker {
pub fn start_str(self) -> &'static str {
match self {
Self::None => "",
Self::Arrow => "<",
Self::Crow => ">",
Self::Dot => "*",
Self::Diamond => "<>",
}
}
pub fn end_str(self) -> &'static str {
match self {
Self::None => "",
Self::Arrow => ">",
Self::Crow => "<",
Self::Dot => "*",
Self::Diamond => "<>",
}
}
}