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),
    ICON(String),
    DESCRIPTION(String),
    ORDER(f32),
    COLOR(u32),
}

#[serde_as]
#[derive(Serialize, Deserialize, Clone, Debug)]
/// Struct representing a Priority of a Todo
///
/// * `title`: the title of the State
/// * `icon`: the icon of the State
/// * `description`: the description of the State
/// * `order`: value of importance (higher = important)
/// * `color`: the color of the State
pub struct Priority {
    title: String,
    icon: String,
    description: String,
    order: f32,
    color: u32,
}

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

impl RodoStruct<FIELDS> for Priority {
    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::ORDER(o) => self.order = o,
            FIELDS::COLOR(c) => self.color = c,
        }
    }
}