rodo_lib 0.1.2

A Library for a Todo Manager
Documentation
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use uuid::Uuid;

use crate::utils::RodoStruct;

pub enum FIELDS {
    TITLE(String),
    DESCRIPTION(String),
    COLOR(u32),
}

#[serde_as]
#[derive(Serialize, Deserialize, Clone, Debug)]
/// Struct representing a Tag
///
/// * `title`: the title of the Tag
/// * `description`: the description of the Tag
/// * `color`: the color of the Tag
pub struct Tag {
    title: String,
    description: String,
    color: u32,
}

impl Tag {
    pub fn new(title: &str, description: &str, color: u32) -> (Uuid, Self) {
        (
            Uuid::new_v4(),
            Self {
                title: String::from(title),
                description: String::from(description),
                color,
            },
        )
    }
}

impl RodoStruct<FIELDS> for Tag {
    fn edit(&mut self, fields: FIELDS) {
        match fields {
            FIELDS::TITLE(t) => self.title = t,
            FIELDS::DESCRIPTION(d) => self.description = d,
            FIELDS::COLOR(c) => self.color = c,
        }
    }
}