diff --git a/src/dav/calencoder.rs b/src/dav/calencoder.rs index 815946e..a2d9a74 100644 --- a/src/dav/calencoder.rs +++ b/src/dav/calencoder.rs @@ -8,6 +8,12 @@ use quick_xml::writer::{ElementWriter, Writer}; use quick_xml::name::PrefixDeclaration; use tokio::io::AsyncWrite; +// =============== Calendar Trait =========================== +pub trait CalContext: Context { + fn create_cal_element(&self, name: &str) -> BytesStart; +} + +// =============== CalDAV Extension Setup =================== impl Context for CalExtension { fn child(&self) -> Self { Self { root: false } @@ -33,6 +39,12 @@ impl Context for CalExtension { } } +impl CalContext for CalExtension { + fn create_cal_element(&self, name: &str) -> BytesStart { + self.create_ns_element("C", name) + } +} + impl CalExtension { fn create_ns_element(&self, ns: &str, name: &str) -> BytesStart { let mut start = BytesStart::new(format!("{}:{}", ns, name)); @@ -42,13 +54,67 @@ impl CalExtension { } start } - fn create_cal_element(&self, name: &str) -> BytesStart { - self.create_ns_element("C", name) +} + +// ==================== Calendar Types Serialization ========================= + +// -------------------- MKCALENDAR METHOD ------------------------------------ +impl QuickWritable for MkCalendar { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); } } -impl QuickWritable for Violation { - async fn write(&self, xml: &mut Writer, ctx: CalExtension) -> Result<(), QError> { +impl QuickWritable for MkCalendarResponse { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +// ----------------------- REPORT METHOD ------------------------------------- + +impl QuickWritable for CalendarQuery { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for CalendarMultiget { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for FreeBusyQuery { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +// -------------------------- DAV::prop -------------------------------------- +impl QuickWritable for Property { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} +impl QuickWritable for PropertyRequest { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +// ---------------------- DAV::resourcetype ---------------------------------- +impl QuickWritable for ResourceType { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + match self { + Self::Calendar => xml.write_event_async(Event::Empty(ctx.create_dav_element("calendar"))).await, + } + } +} + +// --------------------------- DAV::error ------------------------------------ +impl QuickWritable for Violation { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { match self { Self::ResourceMustBeNull => { let start = ctx.create_cal_element("resource-must-be-null"); @@ -61,26 +127,200 @@ impl QuickWritable for Violation { } -impl QuickWritable for Property { - async fn write(&self, xml: &mut Writer, ctx: CalExtension) -> Result<(), QError> { +// ---------------------------- Inner XML ------------------------------------ +impl QuickWritable for SupportedCollation { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { unimplemented!(); } } -impl QuickWritable for PropertyRequest { - async fn write(&self, xml: &mut Writer, ctx: CalExtension) -> Result<(), QError> { +impl QuickWritable for Collation { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { unimplemented!(); } } -impl QuickWritable for ResourceType { - async fn write(&self, xml: &mut Writer, ctx: CalExtension) -> Result<(), QError> { - match self { - Self::Calendar => xml.write_event_async(Event::Empty(ctx.create_dav_element("calendar"))).await, - } +impl QuickWritable for CalendarDataPayload { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); } } +impl QuickWritable for CalendarDataRequest { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for CalendarDataEmpty { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for CalendarDataSupport { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for Comp { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for CompSupport { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for CompKind { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for PropKind { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for CalProp { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for RecurrenceModifier { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for Expand { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for LimitRecurrenceSet { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for LimitFreebusySet { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for CalendarSelector { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for CompFilter { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for CompFilterInner { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for CompFilterMatch { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for PropFilter { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for PropFilterInner { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for PropFilterMatch { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for TimeOrText { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for TextMatch { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for ParamFilter { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for ParamFilterMatch { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for TimeZone { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for Filter { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for Component { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for ComponentProperty { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for PropertyParameter { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + +impl QuickWritable for TimeRange { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + unimplemented!(); + } +} + + #[cfg(test)] mod tests { use super::*; diff --git a/src/dav/caltypes.rs b/src/dav/caltypes.rs index a08f550..3b65fe2 100644 --- a/src/dav/caltypes.rs +++ b/src/dav/caltypes.rs @@ -23,6 +23,8 @@ impl Dav::Extension for CalExtension { // ----- Root elements ----- +// --- (MKCALENDAR PART) --- + /// If a request body is included, it MUST be a CALDAV:mkcalendar XML /// element. Instruction processing MUST occur in the order /// instructions are received (i.e., from top to bottom). @@ -51,6 +53,8 @@ pub struct MkCalendar(Dav::Set); /// pub struct MkCalendarResponse(Vec>); +// --- (REPORT PART) --- + /// Name: calendar-query /// /// Namespace: urn:ietf:params:xml:ns:caldav