diff --git a/crates/dav/src/resource/methods/propfind.rs b/crates/dav/src/resource/methods/propfind.rs index daed710..ae76b00 100644 --- a/crates/dav/src/resource/methods/propfind.rs +++ b/crates/dav/src/resource/methods/propfind.rs @@ -58,24 +58,8 @@ pub(crate) async fn route_propfind( } // A request body is optional. If empty we MUST return all props - let propfind_self: PropfindElement<<::Prop as PropName>::Names> = - if !body.is_empty() { - PropfindElement::parse_str(body).map_err(Error::XmlError)? - } else { - PropfindElement { - prop: PropfindType::Allprop, - include: None, - } - }; - let propfind_member: PropfindElement<<::Prop as PropName>::Names> = - if !body.is_empty() { - PropfindElement::parse_str(body).map_err(Error::XmlError)? - } else { - PropfindElement { - prop: PropfindType::Allprop, - include: None, - } - }; + let propfind_self = R::Resource::parse_propfind(body).map_err(Error::XmlError)?; + let propfind_member = R::MemberType::parse_propfind(body).map_err(Error::XmlError)?; let mut member_responses = Vec::new(); if depth != &Depth::Zero { diff --git a/crates/dav/src/resource/mod.rs b/crates/dav/src/resource/mod.rs index 79b39c9..8fd82df 100644 --- a/crates/dav/src/resource/mod.rs +++ b/crates/dav/src/resource/mod.rs @@ -1,14 +1,16 @@ use crate::Principal; use crate::privileges::UserPrivilegeSet; use crate::xml::multistatus::{PropTagWrapper, PropstatElement, PropstatWrapper}; -use crate::xml::{PropElement, PropfindType, Resourcetype}; +use crate::xml::{PropElement, PropfindElement, PropfindType, Resourcetype}; use crate::xml::{TagList, multistatus::ResponseElement}; use headers::{ETag, IfMatch, IfNoneMatch}; use http::StatusCode; use itertools::Itertools; use quick_xml::name::Namespace; pub use resource_service::ResourceService; -use rustical_xml::{EnumVariants, NamespaceOwned, PropName, XmlDeserialize, XmlSerialize}; +use rustical_xml::{ + EnumVariants, NamespaceOwned, PropName, XmlDeserialize, XmlDocument, XmlSerialize, +}; use std::collections::HashSet; use std::str::FromStr; @@ -102,6 +104,19 @@ pub trait Resource: Clone + Send + 'static { principal: &Self::Principal, ) -> Result; + fn parse_propfind( + body: &str, + ) -> Result::Names>, rustical_xml::XmlError> { + if !body.is_empty() { + PropfindElement::parse_str(body) + } else { + Ok(PropfindElement { + prop: PropfindType::Allprop, + include: None, + }) + } + } + fn propfind( &self, path: &str,