Serialize calendar-data
This commit is contained in:
parent
dba0dcdc41
commit
61ee5f153b
2 changed files with 55 additions and 19 deletions
|
@ -319,37 +319,73 @@ impl<C: CalContext> QuickWritable<C> for Violation {
|
||||||
// ---------------------------- Inner XML ------------------------------------
|
// ---------------------------- Inner XML ------------------------------------
|
||||||
impl<C: CalContext> QuickWritable<C> for SupportedCollation {
|
impl<C: CalContext> QuickWritable<C> for SupportedCollation {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
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 {
|
impl<C: CalContext> QuickWritable<C> for Collation {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
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 {
|
impl<C: CalContext> QuickWritable<C> for CalendarDataPayload {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
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 {
|
impl<C: CalContext> QuickWritable<C> for CalendarDataRequest {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
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 {
|
impl<C: CalContext> QuickWritable<C> for CalendarDataEmpty {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
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
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CalendarDataSupport {
|
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
|
||||||
unimplemented!();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -770,7 +770,7 @@ pub enum Violation {
|
||||||
/// If the client chooses a collation not supported by the server, the
|
/// If the client chooses a collation not supported by the server, the
|
||||||
/// server MUST respond with a CALDAV:supported-collation precondition
|
/// server MUST respond with a CALDAV:supported-collation precondition
|
||||||
/// error response.
|
/// error response.
|
||||||
pub struct SupportedCollation(Collation);
|
pub struct SupportedCollation(pub Collation);
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum Collation {
|
pub enum Collation {
|
||||||
#[default]
|
#[default]
|
||||||
|
@ -799,10 +799,10 @@ pub struct CalendarDataPayload {
|
||||||
/// REPORT request to specify which parts of calendar object
|
/// REPORT request to specify which parts of calendar object
|
||||||
/// resources should be returned in the response;
|
/// resources should be returned in the response;
|
||||||
pub struct CalendarDataRequest {
|
pub struct CalendarDataRequest {
|
||||||
mime: Option<CalendarDataSupport>,
|
pub mime: Option<CalendarDataSupport>,
|
||||||
comp: Option<Comp>,
|
pub comp: Option<Comp>,
|
||||||
reccurence: Option<RecurrenceModifier>,
|
pub recurrence: Option<RecurrenceModifier>,
|
||||||
limit_freebusy_set: Option<LimitFreebusySet>,
|
pub limit_freebusy_set: Option<LimitFreebusySet>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// calendar-data specialization for Property
|
/// calendar-data specialization for Property
|
||||||
|
@ -812,7 +812,7 @@ pub struct CalendarDataRequest {
|
||||||
/// when nested in the CALDAV:supported-calendar-data property
|
/// when nested in the CALDAV:supported-calendar-data property
|
||||||
/// to specify a supported media type for calendar object
|
/// to specify a supported media type for calendar object
|
||||||
/// resources;
|
/// resources;
|
||||||
pub struct CalendarDataEmpty(Option<CalendarDataSupport>);
|
pub struct CalendarDataEmpty(pub Option<CalendarDataSupport>);
|
||||||
|
|
||||||
/// <!ATTLIST calendar-data content-type CDATA "text/calendar"
|
/// <!ATTLIST calendar-data content-type CDATA "text/calendar"
|
||||||
/// version CDATA "2.0">
|
/// version CDATA "2.0">
|
||||||
|
@ -821,8 +821,8 @@ pub struct CalendarDataEmpty(Option<CalendarDataSupport>);
|
||||||
/// attributes can be used on all three variants of the
|
/// attributes can be used on all three variants of the
|
||||||
/// CALDAV:calendar-data XML element.
|
/// CALDAV:calendar-data XML element.
|
||||||
pub struct CalendarDataSupport {
|
pub struct CalendarDataSupport {
|
||||||
content_type: String,
|
pub content_type: String,
|
||||||
version: String,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Name: comp
|
/// Name: comp
|
||||||
|
|
Loading…
Reference in a new issue