#[derive(Debug, Clone, PartialEq)]
pub struct TableBorderChars {
pub horizontal: char,
pub vertical: char,
pub top_left_corner: char,
pub top_right_corner: char,
pub bottom_right_corner: char,
pub bottom_left_corner: char,
pub top_junction: char,
pub right_junction: char,
pub bottom_junction: char,
pub left_junction: char,
pub cross: char,
}
impl TableBorderChars {
pub fn key(&self) -> Option<&'static str> {
if self == STANDARD_TABLE_BORDER_CHARS {
Some("standard")
} else if self == ASCII_TABLE_BORDER_CHARS {
Some("ascii")
} else if self == ROUNDED_TABLE_BORDER_CHARS {
Some("rounded")
} else {
None
}
}
pub fn by_key(key: &str) -> Option<&'static Self> {
match key {
"standard" => Some(STANDARD_TABLE_BORDER_CHARS),
"ascii" => Some(ASCII_TABLE_BORDER_CHARS),
"rounded" => Some(ROUNDED_TABLE_BORDER_CHARS),
_ => None,
}
}
}
pub static STANDARD_TABLE_BORDER_CHARS: &TableBorderChars = &TableBorderChars {
horizontal: '─',
vertical: '│',
top_left_corner: '┌',
top_right_corner: '┐',
bottom_right_corner: '┘',
bottom_left_corner: '└',
top_junction: '┬',
right_junction: '┤',
bottom_junction: '┴',
left_junction: '├',
cross: '┼',
};
pub static ASCII_TABLE_BORDER_CHARS: &TableBorderChars = &TableBorderChars {
horizontal: '-',
vertical: '|',
top_left_corner: '+',
top_right_corner: '+',
bottom_right_corner: '+',
bottom_left_corner: '+',
top_junction: '+',
right_junction: '+',
bottom_junction: '+',
left_junction: '+',
cross: '+',
};
pub static ROUNDED_TABLE_BORDER_CHARS: &TableBorderChars = &TableBorderChars {
horizontal: '─',
vertical: '│',
top_left_corner: '╭',
top_right_corner: '╮',
bottom_right_corner: '╯',
bottom_left_corner: '╰',
top_junction: '┬',
right_junction: '┤',
bottom_junction: '┴',
left_junction: '├',
cross: '┼',
};