use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[cfg_attr(features = "dep:sqlx", derive(sqlx::Type))] pub enum Account { Sumpf, Heinersyndikat, } impl TryFrom<&str> for Account { type Error = (); fn try_from(s: &str) -> Result { match s { "sumpf" => Ok(Account::Sumpf), "hs" => Ok(Account::Heinersyndikat), _ => Err(()), } } } impl Into for &Account { fn into(self) -> String { String::from(match *self { Account::Sumpf => "sumpf", Account::Heinersyndikat => "hs", }) } } impl std::fmt::Display for Account { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { Account::Sumpf => "Sumpf", Account::Heinersyndikat => "Heinersyndikat", } .fmt(f) } }