use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ViewMode {
Table,
List,
Cards,
Compact,
}
impl ViewMode {
pub fn slug(self) -> &'static str {
match self {
ViewMode::Table => "table",
ViewMode::List => "list",
ViewMode::Cards => "cards",
ViewMode::Compact => "compact",
}
}
pub fn from_slug(slug: &str) -> Option<Self> {
match slug {
"table" => Some(ViewMode::Table),
"list" => Some(ViewMode::List),
"cards" => Some(ViewMode::Cards),
"compact" => Some(ViewMode::Compact),
_ => None,
}
}
}