1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use serde_derive::*;
use std::collections::HashMap;
use sync_guid::Guid;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MetaGlobalEngine {
pub version: usize,
#[serde(rename = "syncID")]
pub sync_id: Guid,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MetaGlobalRecord {
#[serde(rename = "syncID")]
pub sync_id: Guid,
#[serde(rename = "storageVersion")]
pub storage_version: usize,
#[serde(default)]
pub engines: HashMap<String, MetaGlobalEngine>,
#[serde(default)]
pub declined: Vec<String>,
}
#[derive(Deserialize, Serialize, Clone, Debug, Eq, PartialEq)]
pub struct CryptoKeysRecord {
pub id: Guid,
pub collection: String,
pub default: [String; 2],
pub collections: HashMap<String, [String; 2]>,
}
#[cfg(test)]
#[test]
fn test_deserialize_meta_global() {
let record = serde_json::json!({
"syncID": "abcd1234abcd",
"storageVersion": 1,
})
.to_string();
let r = serde_json::from_str::<MetaGlobalRecord>(&record).unwrap();
assert_eq!(r.sync_id, "abcd1234abcd");
assert_eq!(r.storage_version, 1);
assert_eq!(r.engines.len(), 0);
assert_eq!(r.declined.len(), 0);
}