webdav_request/res/
multistatus.rs1use super::privilege::CurrentUserPrivilegeSet;
2use serde::Deserialize;
3
4#[derive(Deserialize, Debug)]
5pub struct MultiStatus {
6 #[serde(default)]
7 pub response: Vec<DResponse>,
8}
9
10impl MultiStatus {
11 pub fn parse(s: &str) -> Result<Self, quick_xml::DeError> {
12 quick_xml::de::from_str(s)
13 }
14}
15
16#[derive(Debug, Deserialize, Clone)]
17pub struct DResponse {
18 #[serde(rename = "href")]
19 pub href: String,
20 #[serde(rename = "propstat")]
21 pub prop_stat: PropStat,
22}
23
24impl DResponse {
25 pub fn upwrap(self) -> (String, Prop) {
26 (self.href, self.prop_stat.prop)
27 }
28}
29
30#[derive(Debug, Deserialize, Default, Clone)]
31pub struct PropStat {
32 pub prop: Prop,
33 pub status: String,
34}
35
36#[derive(Debug, Deserialize, Default, Clone)]
37pub struct Prop {
38 #[serde(rename = "displayname")]
39 pub display_name: String,
40 #[serde(default, rename = "getcontenttype")]
41 pub content_type: String,
42 #[serde(default, rename = "getlastmodified")]
43 pub last_modified: String,
44 #[serde(rename = "getcontentlength", default)]
45 pub content_length: u64,
46 #[serde(alias = "iscollection", default)]
47 pub collection: bool,
48 #[serde(rename = "resourcetype", default)]
49 pub resource_type: Option<ResourceType>,
50 #[serde(rename = "current-user-privilege-set", default)]
51 pub current_user_privilege_set: Option<CurrentUserPrivilegeSet>,
52 pub creationdate: Option<String>,
53 pub supportedlock: Option<SupportedLock>,
54}
55
56impl Prop {
57 pub fn is_collection(&self) -> bool {
58 self.collection
59 || self
60 .resource_type
61 .as_ref()
62 .is_some_and(|ty| ty.collection.is_some())
63 }
64}
65
66#[derive(Debug, Clone, Deserialize)]
67pub struct SupportedLock {
68 pub lockentry: Option<LockEntry>,
69}
70
71#[derive(Debug, Clone, Deserialize)]
72pub struct LockEntry {
73 pub lockscope: Option<LockScope>,
74 pub locktype: Option<LockType>,
75}
76
77#[derive(Debug, Clone, Deserialize)]
78pub struct LockScope {
79 pub exclusive: Option<()>,
80}
81
82#[derive(Debug, Clone, Deserialize)]
83pub struct LockType {
84 pub write: Option<()>,
85}
86#[derive(Debug, Deserialize, Default, Clone)]
87pub struct ResourceType {
88 collection: Option<()>,
89}