2022-07-07 11:39:19 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 Ortega Froysa, Nicolás <nicolas@ortegas.org>
|
|
|
|
* Author: Ortega Froysa, Nicolás <nicolas@ortegas.org>
|
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
use uuid::Uuid;
|
2022-07-08 12:08:38 +00:00
|
|
|
use serde::{Serialize, Deserialize};
|
2022-07-07 11:39:19 +00:00
|
|
|
|
2022-07-08 21:07:00 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2022-07-07 11:39:19 +00:00
|
|
|
pub struct Habit
|
|
|
|
{
|
2022-07-08 12:08:38 +00:00
|
|
|
uid:String,
|
2022-07-07 11:39:19 +00:00
|
|
|
name:String,
|
|
|
|
bad:bool,
|
|
|
|
weight:u8,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Habit
|
|
|
|
{
|
|
|
|
pub fn new(name:String, bad:bool, weight:u8) -> Self
|
|
|
|
{
|
|
|
|
Self
|
|
|
|
{
|
2022-07-08 12:08:38 +00:00
|
|
|
uid: Uuid::new_v4().hyphenated().to_string(),
|
2022-07-07 11:39:19 +00:00
|
|
|
name,
|
|
|
|
bad,
|
|
|
|
weight,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-08 12:08:38 +00:00
|
|
|
pub fn get_uid(&self) -> &String { &self.uid }
|
2022-07-07 11:39:19 +00:00
|
|
|
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; }
|
|
|
|
}
|