#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ViewState {
Dashboard, Scan, Fix, Passport, Obligations, Timeline, Report, Log, Chat, }
impl ViewState {
pub const fn from_key(digit: u8) -> Option<Self> {
match digit {
1 => Some(Self::Dashboard),
2 => Some(Self::Scan),
3 => Some(Self::Fix),
4 => Some(Self::Passport),
5 => Some(Self::Obligations),
6 => Some(Self::Timeline),
7 => Some(Self::Report),
8 => Some(Self::Log),
9 => Some(Self::Chat),
_ => None,
}
}
pub const fn from_letter(c: char) -> Option<Self> {
match c {
'D' => Some(Self::Dashboard),
'S' => Some(Self::Scan),
'F' => Some(Self::Fix),
'P' => Some(Self::Passport),
'O' => Some(Self::Obligations),
'T' => Some(Self::Timeline),
'R' => Some(Self::Report),
'L' => Some(Self::Log),
'C' => Some(Self::Chat),
_ => None,
}
}
pub const fn index(self) -> usize {
match self {
Self::Dashboard => 0,
Self::Scan => 1,
Self::Fix => 2,
Self::Passport => 3,
Self::Obligations => 4,
Self::Timeline => 5,
Self::Report => 6,
Self::Log => 7,
Self::Chat => 8,
}
}
pub const fn short_name(self) -> &'static str {
match self {
Self::Dashboard => "Dashboard",
Self::Scan => "Scan",
Self::Fix => "Fix",
Self::Passport => "Passport",
Self::Obligations => "Oblig",
Self::Timeline => "Timeline",
Self::Report => "Report",
Self::Log => "Log",
Self::Chat => "Chat",
}
}
pub const ALL: [Self; 9] = [
Self::Dashboard,
Self::Scan,
Self::Fix,
Self::Passport,
Self::Obligations,
Self::Timeline,
Self::Report,
Self::Log,
Self::Chat,
];
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Mode {
Scan,
Fix,
Watch,
}
impl Mode {
pub const fn next(self) -> Self {
match self {
Self::Scan => Self::Fix,
Self::Fix => Self::Watch,
Self::Watch => Self::Scan,
}
}
}