add a multistatus extension entrypoint

This commit is contained in:
Quentin 2024-05-28 13:04:46 +02:00
parent 10dac17ce1
commit 410d663a5e
Signed by: quentin
GPG key ID: E9602264D639FF68
7 changed files with 21 additions and 0 deletions

View file

@ -1198,6 +1198,7 @@ END:VCALENDAR]]></C:calendar-timezone>
#[tokio::test]
async fn rfc_calendar_query_res() {
let expected = dav::Multistatus::<Calendar> {
extension: None,
responses: vec![
dav::Response {
status_or_propstat: dav::StatusOrPropstat::PropStat(

View file

@ -950,6 +950,7 @@ mod tests {
#[tokio::test]
async fn rfc_calendar_query1_res() {
let got = serialize(&dav::Multistatus::<Calendar> {
extension: None,
responses: vec![
dav::Response {
status_or_propstat: dav::StatusOrPropstat::PropStat(

View file

@ -67,11 +67,13 @@ impl<E: Extension> QRead<Multistatus<E>> for Multistatus<E> {
xml.open(DAV_URN, "multistatus").await?;
let mut responses = Vec::new();
let mut responsedescription = None;
let mut extension = None;
loop {
let mut dirty = false;
xml.maybe_push(&mut responses, &mut dirty).await?;
xml.maybe_read(&mut responsedescription, &mut dirty).await?;
xml.maybe_read(&mut extension, &mut dirty).await?;
if !dirty {
match xml.peek() {
Event::End(_) => break,
@ -84,6 +86,7 @@ impl<E: Extension> QRead<Multistatus<E>> for Multistatus<E> {
Ok(Multistatus {
responses,
responsedescription,
extension,
})
}
}
@ -983,6 +986,7 @@ mod tests {
},
],
responsedescription: None,
extension: None,
}
);
}
@ -1053,6 +1057,7 @@ mod tests {
assert_eq!(
got,
Multistatus {
extension: None,
responses: vec![
Response {
status_or_propstat: StatusOrPropstat::PropStat(

View file

@ -60,6 +60,9 @@ impl<E: Extension> QWrite for Multistatus<E> {
if let Some(description) = &self.responsedescription {
description.qwrite(xml).await?;
}
if let Some(extension) = &self.extension {
extension.qwrite(xml).await?;
}
xml.q.write_event_async(Event::End(end)).await?;
Ok(())
@ -752,6 +755,7 @@ mod tests {
#[tokio::test]
async fn basic_multistatus() {
let orig = Multistatus::<Core> {
extension: None,
responses: vec![],
responsedescription: Some(ResponseDescription("Hello world".into())),
};
@ -808,6 +812,7 @@ mod tests {
#[tokio::test]
async fn rfc_propname_res() {
let orig = Multistatus::<Core> {
extension: None,
responses: vec![
Response {
status_or_propstat: StatusOrPropstat::PropStat(
@ -916,6 +921,7 @@ mod tests {
use chrono::{FixedOffset, TimeZone};
let orig = Multistatus::<Core> {
extension: None,
responses: vec![
Response {
status_or_propstat: StatusOrPropstat::PropStat(
@ -1140,6 +1146,7 @@ mod tests {
#[tokio::test]
async fn rfc_delete_locked2() {
let orig = Multistatus::<Core> {
extension: None,
responses: vec![Response {
status_or_propstat: StatusOrPropstat::Status(
vec![Href("http://www.example.com/container/resource3".into())],

View file

@ -35,6 +35,7 @@ impl dav::Extension for Core {
type ResourceType = Disabled;
type ReportType = Disabled;
type ReportTypeName = Disabled;
type Multistatus = Disabled;
}
// WebDAV with the base Calendar implementation (RFC4791)
@ -47,6 +48,7 @@ impl dav::Extension for Calendar {
type ResourceType = cal::ResourceType;
type ReportType = cal::ReportType<Calendar>;
type ReportTypeName = cal::ReportTypeName;
type Multistatus = Disabled;
}
// ACL
@ -59,6 +61,7 @@ impl dav::Extension for Acl {
type ResourceType = acl::ResourceType;
type ReportType = Disabled;
type ReportTypeName = Disabled;
type Multistatus = Disabled;
}
// All merged
@ -71,6 +74,7 @@ impl dav::Extension for All {
type ResourceType = ResourceType;
type ReportType = ReportType<All>;
type ReportTypeName = ReportTypeName;
type Multistatus = Disabled;
}
#[derive(Debug, PartialEq, Clone)]

View file

@ -13,6 +13,7 @@ pub trait Extension: std::fmt::Debug + PartialEq + Clone {
type ResourceType: xml::Node<Self::ResourceType>;
type ReportType: xml::Node<Self::ReportType>;
type ReportTypeName: xml::Node<Self::ReportTypeName>;
type Multistatus: xml::Node<Self::Multistatus>;
}
/// 14.1. activelock XML Element
@ -338,6 +339,7 @@ pub enum LockType {
pub struct Multistatus<E: Extension> {
pub responses: Vec<Response<E>>,
pub responsedescription: Option<ResponseDescription>,
pub extension: Option<E::Multistatus>,
}
/// 14.17. owner XML Element

View file

@ -309,6 +309,7 @@ impl Controller {
dav::Multistatus::<All> {
responses,
responsedescription: None,
extension: None,
}
}
}