aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dav/calencoder.rs58
-rw-r--r--src/dav/caltypes.rs16
2 files changed, 55 insertions, 19 deletions
diff --git a/src/dav/calencoder.rs b/src/dav/calencoder.rs
index 1016a20..73db4fa 100644
--- a/src/dav/calencoder.rs
+++ b/src/dav/calencoder.rs
@@ -319,37 +319,73 @@ impl<C: CalContext> QuickWritable<C> for Violation {
// ---------------------------- Inner XML ------------------------------------
impl<C: CalContext> QuickWritable<C> for SupportedCollation {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
- unimplemented!();
+ let start = ctx.create_cal_element("supported-collation");
+ let end = start.to_end();
+
+ xml.write_event_async(Event::Start(start.clone())).await?;
+ self.0.write(xml, ctx.child()).await?;
+ xml.write_event_async(Event::End(end)).await
+
}
}
impl<C: CalContext> QuickWritable<C> for Collation {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
- unimplemented!();
+ let col = match self {
+ Self::AsciiCaseMap => "i;ascii-casemap",
+ Self::Octet => "i;octet",
+ Self::Unknown(v) => v.as_str(),
+ };
+
+ xml.write_event_async(Event::Text(BytesText::new(col))).await
}
}
impl<C: CalContext> QuickWritable<C> for CalendarDataPayload {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
- unimplemented!();
+ let mut start = ctx.create_cal_element("calendar-data");
+ if let Some(mime) = &self.mime {
+ start.push_attribute(("content-type", mime.content_type.as_str()));
+ start.push_attribute(("version", mime.version.as_str()));
+ }
+ let end = start.to_end();
+
+ xml.write_event_async(Event::Start(start.clone())).await?;
+ xml.write_event_async(Event::Text(BytesText::new(self.payload.as_str()))).await?;
+ xml.write_event_async(Event::End(end)).await
}
}
impl<C: CalContext> QuickWritable<C> for CalendarDataRequest {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
- unimplemented!();
+ let mut start = ctx.create_cal_element("calendar-data");
+ if let Some(mime) = &self.mime {
+ start.push_attribute(("content-type", mime.content_type.as_str()));
+ start.push_attribute(("version", mime.version.as_str()));
+ }
+ let end = start.to_end();
+ xml.write_event_async(Event::Start(start.clone())).await?;
+ if let Some(comp) = &self.comp {
+ comp.write(xml, ctx.child()).await?;
+ }
+ if let Some(recurrence) = &self.recurrence {
+ recurrence.write(xml, ctx.child()).await?;
+ }
+ if let Some(freebusy) = &self.limit_freebusy_set {
+ freebusy.write(xml, ctx.child()).await?;
+ }
+ xml.write_event_async(Event::End(end)).await
}
}
impl<C: CalContext> QuickWritable<C> for CalendarDataEmpty {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
- unimplemented!();
- }
-}
-
-impl<C: CalContext> QuickWritable<C> for CalendarDataSupport {
- async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
- unimplemented!();
+ let mut empty = ctx.create_cal_element("calendar-data");
+ if let Some(mime) = &self.0 {
+ empty.push_attribute(("content-type", mime.content_type.as_str()));
+ empty.push_attribute(("version", mime.version.as_str()));
+ }
+ xml.write_event_async(Event::Empty(empty)).await
}
}
diff --git a/src/dav/caltypes.rs b/src/dav/caltypes.rs
index 29dc02f..97d75c5 100644
--- a/src/dav/caltypes.rs
+++ b/src/dav/caltypes.rs
@@ -770,7 +770,7 @@ pub enum Violation {
/// If the client chooses a collation not supported by the server, the
/// server MUST respond with a CALDAV:supported-collation precondition
/// error response.
-pub struct SupportedCollation(Collation);
+pub struct SupportedCollation(pub Collation);
#[derive(Default)]
pub enum Collation {
#[default]
@@ -799,10 +799,10 @@ pub struct CalendarDataPayload {
/// REPORT request to specify which parts of calendar object
/// resources should be returned in the response;
pub struct CalendarDataRequest {
- mime: Option<CalendarDataSupport>,
- comp: Option<Comp>,
- reccurence: Option<RecurrenceModifier>,
- limit_freebusy_set: Option<LimitFreebusySet>,
+ pub mime: Option<CalendarDataSupport>,
+ pub comp: Option<Comp>,
+ pub recurrence: Option<RecurrenceModifier>,
+ pub limit_freebusy_set: Option<LimitFreebusySet>,
}
/// calendar-data specialization for Property
@@ -812,7 +812,7 @@ pub struct CalendarDataRequest {
/// when nested in the CALDAV:supported-calendar-data property
/// to specify a supported media type for calendar object
/// resources;
-pub struct CalendarDataEmpty(Option<CalendarDataSupport>);
+pub struct CalendarDataEmpty(pub Option<CalendarDataSupport>);
/// <!ATTLIST calendar-data content-type CDATA "text/calendar"
/// version CDATA "2.0">
@@ -821,8 +821,8 @@ pub struct CalendarDataEmpty(Option<CalendarDataSupport>);
/// attributes can be used on all three variants of the
/// CALDAV:calendar-data XML element.
pub struct CalendarDataSupport {
- content_type: String,
- version: String,
+ pub content_type: String,
+ pub version: String,
}
/// Name: comp