diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-05-28 13:04:46 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-05-28 13:04:46 +0200 |
commit | 410d663a5ecbb6ca46ac049227afdaaaf50ac27f (patch) | |
tree | c5ec222da00e2d6caf9a6c79b12cef3df59e5ef0 | |
parent | 10dac17ce173e584fc857f717f645c05b7cd42ac (diff) | |
download | aerogramme-410d663a5ecbb6ca46ac049227afdaaaf50ac27f.tar.gz aerogramme-410d663a5ecbb6ca46ac049227afdaaaf50ac27f.zip |
add a multistatus extension entrypoint
-rw-r--r-- | aero-dav/src/caldecoder.rs | 1 | ||||
-rw-r--r-- | aero-dav/src/calencoder.rs | 1 | ||||
-rw-r--r-- | aero-dav/src/decoder.rs | 5 | ||||
-rw-r--r-- | aero-dav/src/encoder.rs | 7 | ||||
-rw-r--r-- | aero-dav/src/realization.rs | 4 | ||||
-rw-r--r-- | aero-dav/src/types.rs | 2 | ||||
-rw-r--r-- | aero-proto/src/dav/controller.rs | 1 |
7 files changed, 21 insertions, 0 deletions
diff --git a/aero-dav/src/caldecoder.rs b/aero-dav/src/caldecoder.rs index 0df867f..9ed783a 100644 --- a/aero-dav/src/caldecoder.rs +++ b/aero-dav/src/caldecoder.rs @@ -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( diff --git a/aero-dav/src/calencoder.rs b/aero-dav/src/calencoder.rs index a41747f..15df965 100644 --- a/aero-dav/src/calencoder.rs +++ b/aero-dav/src/calencoder.rs @@ -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( diff --git a/aero-dav/src/decoder.rs b/aero-dav/src/decoder.rs index bd724e8..bb64455 100644 --- a/aero-dav/src/decoder.rs +++ b/aero-dav/src/decoder.rs @@ -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( diff --git a/aero-dav/src/encoder.rs b/aero-dav/src/encoder.rs index fd87e95..6c77aa6 100644 --- a/aero-dav/src/encoder.rs +++ b/aero-dav/src/encoder.rs @@ -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())], diff --git a/aero-dav/src/realization.rs b/aero-dav/src/realization.rs index b37e0f1..1e6f25e 100644 --- a/aero-dav/src/realization.rs +++ b/aero-dav/src/realization.rs @@ -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)] diff --git a/aero-dav/src/types.rs b/aero-dav/src/types.rs index 92c63e0..61a6fe9 100644 --- a/aero-dav/src/types.rs +++ b/aero-dav/src/types.rs @@ -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 diff --git a/aero-proto/src/dav/controller.rs b/aero-proto/src/dav/controller.rs index 1b7f7ee..4bae68a 100644 --- a/aero-proto/src/dav/controller.rs +++ b/aero-proto/src/dav/controller.rs @@ -309,6 +309,7 @@ impl Controller { dav::Multistatus::<All> { responses, responsedescription: None, + extension: None, } } } |