Add JSON support.

This commit is contained in:
2022-07-08 14:08:38 +02:00
parent 1d61c2b439
commit e62722e397
4 changed files with 52 additions and 4 deletions

View File

@ -17,10 +17,12 @@
*/
use uuid::Uuid;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Habit
{
uid:Uuid,
uid:String,
name:String,
bad:bool,
weight:u8,
@ -32,14 +34,14 @@ impl Habit
{
Self
{
uid: Uuid::new_v4(),
uid: Uuid::new_v4().hyphenated().to_string(),
name,
bad,
weight,
}
}
pub fn get_uid(&self) -> String { self.uid.to_string() }
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 }

View File

@ -21,7 +21,6 @@ use structopt::clap::AppSettings;
use std::env;
use std::path::PathBuf;
use std::fs;
//use std::result::Result;
mod habit;
mod habitmgr;