comment_app_frontend 0.1.3

A Comment App Front End Server
Documentation
// status.rs
// status functions are implemented here

use serde_derive::{Serialize, Deserialize};

#[derive(Debug, PartialEq, Copy, Clone, Serialize, Deserialize)]
pub enum Status {
    Pending,    // initial value for a new comment
    Approved,   // moderator approved a comment
    Spam,       // moderator rejected a comment
    Trash,      // moderator expired a comment
    Disabled,   // comment thread or tree is disabled; that means, no further commenting accepted on this thread.
}

impl Status {
    pub fn pending() -> Self { Status::Pending }
    pub fn to_string(&self) -> String {
        match self {
            Status::Pending => String::from("pending"),
            Status::Approved => String::from("approved"),
            Status::Spam => String::from("spam"),
            Status::Trash => String::from("trash"),
            Status::Disabled => String::from("disabled"),
        }
    }
    pub fn from(status: &str) -> Status {
        match status {
            "pending" => Status::Pending,
            "approved" => Status::Approved,
            "spam" => Status::Spam,
            "trash" => Status::Trash,
            "disabled" => Status::Disabled,
            _ => Status::Pending,
        }
    }
    pub fn from_string(status: String) -> Status {
        Self::from(&status)
    }
}