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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
use super::acltypes as acl;
use super::caltypes as cal;
use super::error;
use super::synctypes as sync;
use super::types as dav;
use super::versioningtypes as vers;
use super::xml;
#[derive(Debug, PartialEq, Clone)]
pub struct Disabled(());
impl xml::QRead<Disabled> for Disabled {
async fn qread(_xml: &mut xml::Reader<impl xml::IRead>) -> Result<Self, error::ParsingError> {
Err(error::ParsingError::Recoverable)
}
}
impl xml::QWrite for Disabled {
async fn qwrite(
&self,
_xml: &mut xml::Writer<impl xml::IWrite>,
) -> Result<(), quick_xml::Error> {
unreachable!()
}
}
/// The base WebDAV
///
/// Any extension is disabled through an object we can't build
/// due to a private inner element.
#[derive(Debug, PartialEq, Clone)]
pub struct Core {}
impl dav::Extension for Core {
type Error = Disabled;
type Property = Disabled;
type PropertyRequest = Disabled;
type ResourceType = Disabled;
type ReportType = Disabled;
type ReportTypeName = Disabled;
type Multistatus = Disabled;
}
// WebDAV with the base Calendar implementation (RFC4791)
#[derive(Debug, PartialEq, Clone)]
pub struct Calendar {}
impl dav::Extension for Calendar {
type Error = cal::Violation;
type Property = cal::Property;
type PropertyRequest = cal::PropertyRequest;
type ResourceType = cal::ResourceType;
type ReportType = cal::ReportType<Calendar>;
type ReportTypeName = cal::ReportTypeName;
type Multistatus = Disabled;
}
// ACL
#[derive(Debug, PartialEq, Clone)]
pub struct Acl {}
impl dav::Extension for Acl {
type Error = Disabled;
type Property = acl::Property;
type PropertyRequest = acl::PropertyRequest;
type ResourceType = acl::ResourceType;
type ReportType = Disabled;
type ReportTypeName = Disabled;
type Multistatus = Disabled;
}
// All merged
#[derive(Debug, PartialEq, Clone)]
pub struct All {}
impl dav::Extension for All {
type Error = cal::Violation;
type Property = Property<All>;
type PropertyRequest = PropertyRequest;
type ResourceType = ResourceType;
type ReportType = ReportType<All>;
type ReportTypeName = ReportTypeName;
type Multistatus = Multistatus;
}
#[derive(Debug, PartialEq, Clone)]
pub enum Property<E: dav::Extension> {
Cal(cal::Property),
Acl(acl::Property),
Sync(sync::Property),
Vers(vers::Property<E>),
}
impl<E: dav::Extension> xml::QRead<Property<E>> for Property<E> {
async fn qread(xml: &mut xml::Reader<impl xml::IRead>) -> Result<Self, error::ParsingError> {
match cal::Property::qread(xml).await {
Err(error::ParsingError::Recoverable) => (),
otherwise => return otherwise.map(Property::<E>::Cal),
}
match acl::Property::qread(xml).await {
Err(error::ParsingError::Recoverable) => (),
otherwise => return otherwise.map(Property::Acl),
}
match sync::Property::qread(xml).await {
Err(error::ParsingError::Recoverable) => (),
otherwise => return otherwise.map(Property::Sync),
}
vers::Property::qread(xml).await.map(Property::Vers)
}
}
impl<E: dav::Extension> xml::QWrite for Property<E> {
async fn qwrite(
&self,
xml: &mut xml::Writer<impl xml::IWrite>,
) -> Result<(), quick_xml::Error> {
match self {
Self::Cal(c) => c.qwrite(xml).await,
Self::Acl(a) => a.qwrite(xml).await,
Self::Sync(s) => s.qwrite(xml).await,
Self::Vers(v) => v.qwrite(xml).await,
}
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum PropertyRequest {
Cal(cal::PropertyRequest),
Acl(acl::PropertyRequest),
Sync(sync::PropertyRequest),
Vers(vers::PropertyRequest),
}
impl xml::QRead<PropertyRequest> for PropertyRequest {
async fn qread(xml: &mut xml::Reader<impl xml::IRead>) -> Result<Self, error::ParsingError> {
match cal::PropertyRequest::qread(xml).await {
Err(error::ParsingError::Recoverable) => (),
otherwise => return otherwise.map(PropertyRequest::Cal),
}
match acl::PropertyRequest::qread(xml).await {
Err(error::ParsingError::Recoverable) => (),
otherwise => return otherwise.map(PropertyRequest::Acl),
}
match sync::PropertyRequest::qread(xml).await {
Err(error::ParsingError::Recoverable) => (),
otherwise => return otherwise.map(PropertyRequest::Sync),
}
vers::PropertyRequest::qread(xml)
.await
.map(PropertyRequest::Vers)
}
}
impl xml::QWrite for PropertyRequest {
async fn qwrite(
&self,
xml: &mut xml::Writer<impl xml::IWrite>,
) -> Result<(), quick_xml::Error> {
match self {
Self::Cal(c) => c.qwrite(xml).await,
Self::Acl(a) => a.qwrite(xml).await,
Self::Sync(s) => s.qwrite(xml).await,
Self::Vers(v) => v.qwrite(xml).await,
}
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum ResourceType {
Cal(cal::ResourceType),
Acl(acl::ResourceType),
}
impl xml::QRead<ResourceType> for ResourceType {
async fn qread(xml: &mut xml::Reader<impl xml::IRead>) -> Result<Self, error::ParsingError> {
match cal::ResourceType::qread(xml).await {
Err(error::ParsingError::Recoverable) => (),
otherwise => return otherwise.map(ResourceType::Cal),
}
acl::ResourceType::qread(xml).await.map(ResourceType::Acl)
}
}
impl xml::QWrite for ResourceType {
async fn qwrite(
&self,
xml: &mut xml::Writer<impl xml::IWrite>,
) -> Result<(), quick_xml::Error> {
match self {
Self::Cal(c) => c.qwrite(xml).await,
Self::Acl(a) => a.qwrite(xml).await,
}
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum ReportType<E: dav::Extension> {
Cal(cal::ReportType<E>),
Sync(sync::SyncCollection<E>),
}
impl<E: dav::Extension> xml::QRead<ReportType<E>> for ReportType<E> {
async fn qread(
xml: &mut xml::Reader<impl xml::IRead>,
) -> Result<ReportType<E>, error::ParsingError> {
match cal::ReportType::qread(xml).await {
Err(error::ParsingError::Recoverable) => (),
otherwise => return otherwise.map(ReportType::Cal),
}
sync::SyncCollection::qread(xml).await.map(ReportType::Sync)
}
}
impl<E: dav::Extension> xml::QWrite for ReportType<E> {
async fn qwrite(
&self,
xml: &mut xml::Writer<impl xml::IWrite>,
) -> Result<(), quick_xml::Error> {
match self {
Self::Cal(c) => c.qwrite(xml).await,
Self::Sync(s) => s.qwrite(xml).await,
}
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum ReportTypeName {
Cal(cal::ReportTypeName),
Sync(sync::ReportTypeName),
}
impl xml::QRead<ReportTypeName> for ReportTypeName {
async fn qread(xml: &mut xml::Reader<impl xml::IRead>) -> Result<Self, error::ParsingError> {
match cal::ReportTypeName::qread(xml).await {
Err(error::ParsingError::Recoverable) => (),
otherwise => return otherwise.map(ReportTypeName::Cal),
}
sync::ReportTypeName::qread(xml)
.await
.map(ReportTypeName::Sync)
}
}
impl xml::QWrite for ReportTypeName {
async fn qwrite(
&self,
xml: &mut xml::Writer<impl xml::IWrite>,
) -> Result<(), quick_xml::Error> {
match self {
Self::Cal(c) => c.qwrite(xml).await,
Self::Sync(s) => s.qwrite(xml).await,
}
}
}
#[derive(Debug, PartialEq, Clone)]
pub enum Multistatus {
Sync(sync::Multistatus),
}
impl xml::QWrite for Multistatus {
async fn qwrite(
&self,
xml: &mut xml::Writer<impl xml::IWrite>,
) -> Result<(), quick_xml::Error> {
match self {
Self::Sync(s) => s.qwrite(xml).await,
}
}
}
impl xml::QRead<Multistatus> for Multistatus {
async fn qread(xml: &mut xml::Reader<impl xml::IRead>) -> Result<Self, error::ParsingError> {
sync::Multistatus::qread(xml).await.map(Self::Sync)
}
}
|