|
|
@ -1,19 +1,19 @@
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
|
|
|
|
use serde::Serialize;
|
|
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
use serde_with::serde_as;
|
|
|
|
use serde_with::serde_as;
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize)]
|
|
|
|
#[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize, Deserialize)]
|
|
|
|
struct Path(pub Vec<u32>);
|
|
|
|
struct Path(pub Vec<u32>);
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
struct Rel {
|
|
|
|
struct Rel {
|
|
|
|
path: Path,
|
|
|
|
path: Path,
|
|
|
|
count: usize,
|
|
|
|
count: usize,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[serde_as]
|
|
|
|
#[serde_as]
|
|
|
|
#[derive(Serialize)]
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
struct Cl1 {
|
|
|
|
struct Cl1 {
|
|
|
|
#[serde_as(as = "Vec<(_, _)>")]
|
|
|
|
#[serde_as(as = "Vec<(_, _)>")]
|
|
|
|
cache: HashMap<Vec<u32>, String>,
|
|
|
|
cache: HashMap<Vec<u32>, String>,
|
|
|
@ -21,7 +21,7 @@ struct Cl1 {
|
|
|
|
|
|
|
|
|
|
|
|
type RelCache = HashMap<Path, Rel>;
|
|
|
|
type RelCache = HashMap<Path, Rel>;
|
|
|
|
#[serde_as]
|
|
|
|
#[serde_as]
|
|
|
|
#[derive(Serialize)]
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
struct Cl2 {
|
|
|
|
struct Cl2 {
|
|
|
|
#[serde_as(as = "Vec<(_, _)>")]
|
|
|
|
#[serde_as(as = "Vec<(_, _)>")]
|
|
|
|
cache: RelCache,
|
|
|
|
cache: RelCache,
|
|
|
@ -54,6 +54,8 @@ fn main() {
|
|
|
|
cache
|
|
|
|
cache
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let json = serde_json::to_string(&cl);
|
|
|
|
let json = serde_json::to_string(&cl).unwrap();
|
|
|
|
dbg!(json);
|
|
|
|
dbg!(&json);
|
|
|
|
|
|
|
|
let obj: Cl2 = serde_json::from_str(&json).unwrap();
|
|
|
|
|
|
|
|
dbg!(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|