/* * Copyright (C) 2022 Ortega Froysa, Nicolás * Author: Ortega Froysa, Nicolás * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ use uuid::Uuid; use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize)] pub struct Habit { uid:String, name:String, bad:bool, weight:u8, } impl Habit { pub fn new(name:String, bad:bool, weight:u8) -> Self { Self { uid: Uuid::new_v4().hyphenated().to_string(), name, bad, weight, } } pub fn get_uid(&self) -> &String { &self.uid } pub fn get_name(&self) -> &String { &self.name } pub fn get_bad(&self) -> bool { self.bad } pub fn get_weight(&self) -> u8 { self.weight } pub fn set_name(&mut self, name:String) { self.name = name; } pub fn set_bad(&mut self, bad:bool) { self.bad = bad; } pub fn set_weight(&mut self, weight:u8) { self.weight = weight; } }