use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use uuid::Uuid;
use crate::utils::RodoStruct;
pub enum FIELDS {
TITLE(String),
ICON(String),
DESCRIPTION(String),
WORKING(bool),
COLOR(u32),
}
#[serde_as]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct State {
title: String,
icon: String,
description: String,
working: bool,
color: u32,
}
impl State {
pub fn new(
title: &str,
icon: &str,
description: &str,
working: bool,
color: u32,
) -> (Uuid, Self) {
(
Uuid::new_v4(),
Self {
title: String::from(title),
icon: String::from(icon),
description: String::from(description),
working,
color,
},
)
}
}
impl RodoStruct<FIELDS> for State {
fn edit(&mut self, fields: FIELDS) {
match fields {
FIELDS::TITLE(t) => self.title = t,
FIELDS::ICON(i) => self.icon = i,
FIELDS::DESCRIPTION(d) => self.description = d,
FIELDS::WORKING(w) => self.working = w,
FIELDS::COLOR(c) => self.color = c,
}
}
}