
// use serde::{Deserialize, Serialize};

#[derive(Clone)]
pub enum UserAction {
    Access,
    Log(String),
    Request(String),
    View(String),
    List(String),
    Profile(String),
    Other,
}
impl Default for UserAction {
    fn default() -> Self {
        UserAction::Other
    }
}
impl std::fmt::Display for UserAction {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
           UserAction::Access => write!(f,"access"),
           UserAction::Log(info) =>write!(f,"log: {}", info),
           UserAction::Request(info) =>write!(f,"request: {}", info),
           UserAction::View(info) => write!(f,"view: {}", info),
           UserAction::List(info) => write!(f,"list: {}", info),
           UserAction::Profile( info) => write!(f,"profile: {}", info),
           UserAction::Other => write!(f,"other"),
        }
    }
}
impl UserAction {
    #[allow(dead_code)]
    pub fn from_str(value: &str, info: String) -> UserAction {
        match value {
            "access" | "Access" => UserAction::Access,
            "log" | "Log" => UserAction::Log(info),
            "request" | "Request" => UserAction::Request(info),
            "view" | "View" => UserAction::View(info),
            "list" | "List" => UserAction::List(info),
            "profile" | "Profile " => UserAction::Profile(info),
            "other" | "Other " => UserAction::Other,
            _ => UserAction::default(),
        }
    }
    #[allow(dead_code)]
    pub fn info(&self) -> String {
        match self {
            UserAction::Access => String::from(""),
            UserAction::Log(info) => info.to_owned(),
            UserAction::Request(info) => info.to_owned(),
            UserAction::View(info) => info.to_owned(),
            UserAction::List(info) => info.to_owned(),
            UserAction::Profile(info) => info.to_owned(),
            UserAction::Other => String::from(""),
        }
    }
}