webdav_request/res/
multistatus.rs

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
use serde::Deserialize;


#[derive(Deserialize, Debug)]
pub struct MultiStatus {
    #[serde(default)]
    pub response: Vec<DResponse>,
}

impl MultiStatus {
    #[allow(clippy::should_implement_trait)]
    pub fn from_str(s: &str) -> Result<Self, quick_xml::DeError> {
        quick_xml::de::from_str(s)
    }
}

#[derive(Debug, Deserialize)]
pub struct DResponse {
    #[serde(rename = "href")]
    pub href: String,
    #[serde(rename = "propstat")]
    pub prop_stat: PropStat,
}

#[derive(Debug, Deserialize, Default)]
pub struct PropStat {
    pub prop: Prop,
    pub status: String,
}

#[derive(Debug, Deserialize, Default)]
pub struct Prop {
    #[serde(rename = "displayname")]
    pub display_name: String,
    #[serde(default, rename = "getcontenttype")]
    pub content_type: String,
    #[serde(default, rename = "getlastmodified")]
    pub last_modified: String,
    #[serde(rename = "getcontentlength", default)]
    pub content_length: u64,
    #[serde(alias = "iscollection", default)]
    pub collection: bool,
    #[serde(rename = "resourcetype", default)]
    pub resource_type: Option<ResourceType>,
}

impl Prop {
    pub fn is_collection(&self) -> bool {
        self.collection
            || self
                .resource_type
                .as_ref()
                .is_some_and(|ty| ty.collection.is_some())
    }
}

#[derive(Debug, Deserialize, Default)]
pub struct ResourceType {
    #[serde(default)]
    collection: Option<String>,
}