server from db working
This commit is contained in:
@ -4,6 +4,7 @@ use diesel::expression::AsExpression;
|
||||
use diesel::pg::Pg;
|
||||
use diesel::serialize::{self, ToSql, Output};
|
||||
use diesel::sql_types::SmallInt;
|
||||
use std::fmt::{self, write};
|
||||
use std::io::Write;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, AsExpression, FromSqlRow, serde::Serialize, serde::Deserialize)]
|
||||
@ -14,7 +15,7 @@ pub enum ServerStatus {
|
||||
Stopping = 2,
|
||||
Starting = 3,
|
||||
Running = 4,
|
||||
Unknown = 5,
|
||||
Unknown = 5
|
||||
}
|
||||
|
||||
impl ToSql<SmallInt, Pg> for ServerStatus {
|
||||
@ -42,3 +43,18 @@ impl FromSql<SmallInt, Pg> for ServerStatus {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ServerStatus {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let str_status = match self {
|
||||
ServerStatus::Archived => "archieved",
|
||||
ServerStatus::Stopped => "stopped",
|
||||
ServerStatus::Stopping => "stopping",
|
||||
ServerStatus::Starting => "starting",
|
||||
ServerStatus::Running => "running",
|
||||
ServerStatus::Unknown => "(error : unknown status)"
|
||||
|
||||
};
|
||||
write!(f, "{}", str_status)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user