From f50f6d68aa8c3bc363fb71bc75a2c1f78f14803f Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 8 Mar 2024 21:51:34 +0100 Subject: finalize decoder caldav impl --- aero-dav/src/caldecoder.rs | 55 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/aero-dav/src/caldecoder.rs b/aero-dav/src/caldecoder.rs index 11e191f..1a096c1 100644 --- a/aero-dav/src/caldecoder.rs +++ b/aero-dav/src/caldecoder.rs @@ -230,14 +230,61 @@ impl QRead for Property { } impl QRead for PropertyRequest { - async fn qread(_xml: &mut Reader) -> Result { - unreachable!(); + async fn qread(xml: &mut Reader) -> Result { + if xml.maybe_open(CAL_URN, "calendar-description").await?.is_some() { + xml.close().await?; + return Ok(Self::CalendarDescription) + } + if xml.maybe_open(CAL_URN, "calendar-timezone").await?.is_some() { + xml.close().await?; + return Ok(Self::CalendarTimezone) + } + if xml.maybe_open(CAL_URN, "supported-calendar-component-set").await?.is_some() { + xml.close().await?; + return Ok(Self::SupportedCalendarComponentSet) + } + if xml.maybe_open(CAL_URN, "supported-calendar-data").await?.is_some() { + xml.close().await?; + return Ok(Self::SupportedCalendarData) + } + if xml.maybe_open(CAL_URN, "max-resource-size").await?.is_some() { + xml.close().await?; + return Ok(Self::MaxResourceSize) + } + if xml.maybe_open(CAL_URN, "min-date-time").await?.is_some() { + xml.close().await?; + return Ok(Self::MinDateTime) + } + if xml.maybe_open(CAL_URN, "max-date-time").await?.is_some() { + xml.close().await?; + return Ok(Self::MaxDateTime) + } + if xml.maybe_open(CAL_URN, "max-instances").await?.is_some() { + xml.close().await?; + return Ok(Self::MaxInstances) + } + if xml.maybe_open(CAL_URN, "max-attendees-per-instance").await?.is_some() { + xml.close().await?; + return Ok(Self::MaxAttendeesPerInstance) + } + if xml.maybe_open(CAL_URN, "supported-collation-set").await?.is_some() { + xml.close().await?; + return Ok(Self::SupportedCollationSet) + } + let mut dirty = false; + let mut m_cdr = None; + xml.maybe_read(&mut m_cdr, &mut dirty).await?; + m_cdr.ok_or(ParsingError::Recoverable).map(Self::CalendarData) } } impl QRead for ResourceType { - async fn qread(_xml: &mut Reader) -> Result { - unreachable!(); + async fn qread(xml: &mut Reader) -> Result { + if xml.maybe_open(CAL_URN, "calendar").await?.is_some() { + xml.close().await?; + return Ok(Self::Calendar) + } + Err(ParsingError::Recoverable) } } -- cgit v1.2.3