62 lines
1.5 KiB
Rust
62 lines
1.5 KiB
Rust
|
#[derive(Clone)]
|
||
|
pub struct Task {
|
||
|
pub id: i32,
|
||
|
pub label: TaskLabel,
|
||
|
pub title: String,
|
||
|
pub status: TaskStatus,
|
||
|
}
|
||
|
|
||
|
#[derive(Clone)]
|
||
|
enum TaskLabel {
|
||
|
Bug,
|
||
|
Feature,
|
||
|
Documentation,
|
||
|
}
|
||
|
|
||
|
#[derive(Clone)]
|
||
|
enum TaskStatus {
|
||
|
Backlog {},
|
||
|
}
|
||
|
|
||
|
impl TaskStatus {
|
||
|
fn new(status: &str) -> Option<Self> {
|
||
|
match status {
|
||
|
"pending" => Some(TaskStatus::Backlog {
|
||
|
icon: "🕒",
|
||
|
title: "Backlog",
|
||
|
}),
|
||
|
"in_progress" => Some(TaskStatus::InProgress {
|
||
|
icon: "⚙️",
|
||
|
title: "In Progress",
|
||
|
}),
|
||
|
"completed" => Some(TaskStatus::Completed {
|
||
|
icon: "✔️",
|
||
|
title: "Completed",
|
||
|
}),
|
||
|
"failed" => Some(TaskStatus::Failed {
|
||
|
icon: "❌",
|
||
|
title: "Failed",
|
||
|
}),
|
||
|
_ => None,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn icon(&self) -> &'static str {
|
||
|
match self {
|
||
|
TaskStatus::Pending { icon, .. } => icon,
|
||
|
TaskStatus::InProgress { icon, .. } => icon,
|
||
|
TaskStatus::Completed { icon, .. } => icon,
|
||
|
TaskStatus::Failed { icon, .. } => icon,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn title(&self) -> &'static str {
|
||
|
match self {
|
||
|
TaskStatus::Pending { title, .. } => title,
|
||
|
TaskStatus::InProgress { title, .. } => title,
|
||
|
TaskStatus::Completed { title, .. } => title,
|
||
|
TaskStatus::Failed { title, .. } => title,
|
||
|
}
|
||
|
}
|
||
|
}
|