use serde::{Deserialize, Serialize};
use sqlx::Type;
use std::str::FromStr;
#[cfg(feature = "openapi")]
use utoipa::ToSchema;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Type)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
#[serde(rename_all = "snake_case")]
#[sqlx(type_name = "request_kanban_state", rename_all = "snake_case")]
pub enum RequestKanbanState {
Normal,
Blocked,
Done,
}
impl std::fmt::Display for RequestKanbanState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Normal => write!(f, "normal"),
Self::Blocked => write!(f, "blocked"),
Self::Done => write!(f, "done"),
}
}
}
impl FromStr for RequestKanbanState {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"normal" => Ok(Self::Normal),
"blocked" => Ok(Self::Blocked),
"done" => Ok(Self::Done),
_ => Err(format!("Unknown RequestKanbanState variant: {}", s)),
}
}
}
impl Default for RequestKanbanState {
fn default() -> Self {
Self::Normal
}
}