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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
use crate::{create_binding, create_details, Error, create_calls};
use serde::{Deserialize, Serialize};
create_calls! {
FolderApi where
Endpoint = "1.0/folder",
Details: Details,
Type: Folder,
Create: CreateFolder,
Update: UpdateFolder,
Error: Error,
Identifier: FolderIdentifier,
Trashed: TrashedIdentifier,
Criteria: FolderSearch
{
List;
pub async fn list(&self, details: Option<Details>) -> Result<Vec<Type>, Error>;
Get;
pub async fn get(&self, details: Option<Details>, id: uuid::Uuid) -> Result<Type, Error>;
Find;
pub async fn find(&self, criteria: Criteria, details: Option<Details>) -> Result<Vec<Type>, Error>;
Create;
pub async fn create(&self, value: Create) -> Result<Identifier, Error>;
Update;
pub async fn update(&self, value: Update) -> Result<Identifier, Error>;
Delete;
pub async fn delete(&self, id: uuid::Uuid, revision: Option<uuid::Uuid>) -> Result<Trashed, Error>;
Restore;
pub async fn restore(&self, id: uuid::Uuid, revision: Option<uuid::Uuid>) -> Result<Identifier, Error>;
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct FolderIdentifier {
pub id: uuid::Uuid,
pub revision: uuid::Uuid,
}
#[derive(Serialize, Deserialize)]
pub struct TrashedIdentifier {
pub id: uuid::Uuid,
pub revision: Option<uuid::Uuid>,
}
create_details! {
pub struct Details {
pub revisions: bool,
pub parent: bool,
pub folders: bool,
pub passwords: bool,
pub tags: bool,
}
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(untagged)]
pub enum ParentInfoKind {
Id(uuid::Uuid),
Data(Box<crate::folder::Folder>),
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(transparent)]
pub struct ParentInfo(ParentInfoKind);
impl ParentInfo {
pub fn get(&self) -> &ParentInfoKind {
&self.0
}
pub fn new(id: uuid::Uuid) -> Self {
Self(ParentInfoKind::Id(id))
}
}
create_binding! {
#[derive(Serialize, Deserialize, Debug)]
pub struct Folder {
pub id: uuid::Uuid [update(required) versioned(false)],
pub label: String [versioned(true) create(required) update(required)],
pub parent: ParentInfo [versioned(true) create(optional) update(optional) search],
pub created: u64 [search versioned(false)],
pub updated: u64 [versioned(true) search],
pub edited: u64 [versioned(true) update(optional)],
pub revision: uuid::Uuid [versioned(true)],
#[serde(rename = "cseType")]
pub cse_type: String [versioned(true) create(optional) update(optional) search],
#[serde(rename = "cseKey")]
pub cse_key: String [versioned(true) create(optional) update(optional)],
#[serde(rename = "sseType")]
pub sse_type: String [versioned(true) search],
pub client: String [versioned(true)],
pub hidden: bool [versioned(true) create(optional) update(optional)],
pub trashed: bool [versioned(true) search],
pub favorite: bool [versioned(true) create(optional) update(optional) search],
pub revisions: Option<Vec<VersionedFolder>> [versioned(false)],
pub folders: Option<Vec<Folder>> [versioned(false)],
pub passwords: Option<Vec<crate::password::Password>> [versioned(false)],
}
}