rustical_dav/xml/
sync_collection.rs1use rustical_xml::{ValueDeserialize, ValueSerialize, XmlDeserialize};
2
3use super::{PropfindType, Propname};
4
5#[derive(Clone, Debug, PartialEq)]
6pub enum SyncLevel {
7 One,
8 Infinity,
9}
10
11impl ValueDeserialize for SyncLevel {
12 fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
13 Ok(match val {
14 "1" => Self::One,
15 "Infinity" => Self::Infinity,
16 _ => {
17 return Err(rustical_xml::XmlError::InvalidValue(
18 rustical_xml::ParseValueError::Other("Invalid sync-level".to_owned()),
19 ));
20 }
21 })
22 }
23}
24
25impl ValueSerialize for SyncLevel {
26 fn serialize(&self) -> String {
27 match self {
28 SyncLevel::One => "1",
29 SyncLevel::Infinity => "Infinity",
30 }
31 .to_owned()
32 }
33}
34
35#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
36#[xml(ns = "crate::namespace::NS_DAV")]
40pub struct SyncCollectionRequest<PN: XmlDeserialize = Propname> {
41 #[xml(ns = "crate::namespace::NS_DAV")]
42 pub sync_token: String,
43 #[xml(ns = "crate::namespace::NS_DAV")]
44 pub sync_level: SyncLevel,
45 #[xml(ns = "crate::namespace::NS_DAV", ty = "untagged")]
46 pub prop: PropfindType<PN>,
47 #[xml(ns = "crate::namespace::NS_DAV")]
48 pub limit: Option<u64>,
49}