Add JSON support.
This commit is contained in:
parent
1d61c2b439
commit
e62722e397
45
Cargo.lock
generated
45
Cargo.lock
generated
@ -82,10 +82,18 @@ dependencies = [
|
|||||||
name = "htracker"
|
name = "htracker"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"structopt",
|
"structopt",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@ -176,6 +184,43 @@ dependencies = [
|
|||||||
"getrandom",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.138"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.138"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.82"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
@ -12,3 +12,5 @@ license = "AGPL-3.0-or-later"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
structopt = "0.3"
|
structopt = "0.3"
|
||||||
uuid = { version = "1.1", features = [ "v4", "fast-rng", "macro-diagnostics" ] }
|
uuid = { version = "1.1", features = [ "v4", "fast-rng", "macro-diagnostics" ] }
|
||||||
|
serde = { version = "1.0", features = [ "derive" ] }
|
||||||
|
serde_json = "1.0"
|
||||||
|
@ -17,10 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct Habit
|
pub struct Habit
|
||||||
{
|
{
|
||||||
uid:Uuid,
|
uid:String,
|
||||||
name:String,
|
name:String,
|
||||||
bad:bool,
|
bad:bool,
|
||||||
weight:u8,
|
weight:u8,
|
||||||
@ -32,14 +34,14 @@ impl Habit
|
|||||||
{
|
{
|
||||||
Self
|
Self
|
||||||
{
|
{
|
||||||
uid: Uuid::new_v4(),
|
uid: Uuid::new_v4().hyphenated().to_string(),
|
||||||
name,
|
name,
|
||||||
bad,
|
bad,
|
||||||
weight,
|
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_name(&self) -> &String { &self.name }
|
||||||
pub fn get_bad(&self) -> bool { self.bad }
|
pub fn get_bad(&self) -> bool { self.bad }
|
||||||
pub fn get_weight(&self) -> u8 { self.weight }
|
pub fn get_weight(&self) -> u8 { self.weight }
|
||||||
|
@ -21,7 +21,6 @@ use structopt::clap::AppSettings;
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
//use std::result::Result;
|
|
||||||
|
|
||||||
mod habit;
|
mod habit;
|
||||||
mod habitmgr;
|
mod habitmgr;
|
||||||
|
Loading…
Reference in New Issue
Block a user