tmux_interface/styles/
align.rs1use std::fmt;
2use std::str::FromStr;
3
4const LEFT: &str = "left";
5const CENTRE: &str = "centre";
6const RIGHT: &str = "right";
7
8#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
9pub enum Align {
10 Left,
11 Centre,
12 Right,
13}
14
15impl fmt::Display for Align {
16 fn fmt<'a>(&self, f: &mut fmt::Formatter) -> fmt::Result {
17 let s = match self {
18 Self::Left => LEFT,
19 Self::Centre => CENTRE,
20 Self::Right => RIGHT,
21 };
22 write!(f, "{}", s)
23 }
24}
25
26impl FromStr for Align {
27 type Err = ();
28
29 fn from_str(s: &str) -> Result<Self, Self::Err> {
30 match s {
31 LEFT => Ok(Self::Left),
32 CENTRE => Ok(Self::Centre),
33 RIGHT => Ok(Self::Right),
34 _ => Err(()),
35 }
36 }
37}