1use serde::{Deserialize, Serialize};
2use serde_json::Value as JsonValue;
3
4use api::DecsyncAPI;
5
6mod api;
7mod hash;
8mod v2;
9
10#[derive(Serialize, Deserialize)]
11pub struct Entry {
12 datetime: String,
13 key: JsonValue,
14 value: JsonValue,
15}
16
17#[derive(Serialize, Deserialize)]
18pub struct EntryWithPath {
19 path: Vec<String>,
20 entry: Entry,
21}
22
23#[derive(Serialize, Deserialize)]
24pub struct StoredEntry {
25 path: Vec<String>,
26 key: JsonValue,
27}
28
29pub enum Version {
30 V1,
31 V2,
32}
33
34pub struct Decsync {}
35
36impl<'a> Decsync {
37 pub fn constructor(
38 decsync_dir: String,
39 local_dir: String,
40 sync_type: String,
41 collection: Option<String>,
42 own_app_id: String,
43 ) -> Box<dyn DecsyncAPI<'a>> {
44 let version = Version::V2;
46
47 let api = match version {
48 Version::V2 => v2::Decsync::new(
49 decsync_dir,
50 local_dir,
51 sync_type,
52 collection,
53 own_app_id,
54 ),
55 _ => panic!("not implemented yet :'("),
56 };
57 Box::new(api)
58 }
59}