Re-enable calendar encoder
This commit is contained in:
parent
f376e88c73
commit
8fec92a086
2 changed files with 278 additions and 296 deletions
|
@ -1,141 +1,94 @@
|
||||||
/*
|
|
||||||
use super::encoder::{QuickWritable, Context};
|
|
||||||
use super::caltypes::*;
|
|
||||||
use super::types::Extension;
|
|
||||||
|
|
||||||
use quick_xml::Error as QError;
|
use quick_xml::Error as QError;
|
||||||
use quick_xml::events::{Event, BytesEnd, BytesStart, BytesText};
|
use quick_xml::events::{Event, BytesEnd, BytesStart, BytesText};
|
||||||
use quick_xml::writer::{ElementWriter, Writer};
|
|
||||||
use quick_xml::name::PrefixDeclaration;
|
use quick_xml::name::PrefixDeclaration;
|
||||||
use tokio::io::AsyncWrite;
|
use tokio::io::AsyncWrite;
|
||||||
|
|
||||||
|
use super::caltypes::*;
|
||||||
|
use super::xml::{QWrite, IWrite, Writer};
|
||||||
|
use super::types::Extension;
|
||||||
|
|
||||||
const ICAL_DATETIME_FMT: &str = "%Y%m%dT%H%M%SZ";
|
const ICAL_DATETIME_FMT: &str = "%Y%m%dT%H%M%SZ";
|
||||||
|
|
||||||
// =============== 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 }
|
|
||||||
}
|
|
||||||
fn create_dav_element(&self, name: &str) -> BytesStart {
|
|
||||||
self.create_ns_element("D", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn hook_error(&self, err: &Violation, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
|
|
||||||
err.write(xml, self.child()).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn hook_property(&self, prop: &Self::Property, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
|
|
||||||
prop.write(xml, self.child()).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn hook_resourcetype(&self, restype: &Self::ResourceType, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
|
|
||||||
restype.write(xml, self.child()).await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn hook_propertyrequest(&self, propreq: &Self::PropertyRequest, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
|
|
||||||
propreq.write(xml, self.child()).await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
|
||||||
if self.root {
|
|
||||||
start.push_attribute(("xmlns:D", "DAV:"));
|
|
||||||
start.push_attribute(("xmlns:C", "urn:ietf:params:xml:ns:caldav"));
|
|
||||||
}
|
|
||||||
start
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== Calendar Types Serialization =========================
|
// ==================== Calendar Types Serialization =========================
|
||||||
|
|
||||||
// -------------------- MKCALENDAR METHOD ------------------------------------
|
// -------------------- MKCALENDAR METHOD ------------------------------------
|
||||||
impl<C: CalContext> QuickWritable<C> for MkCalendar<C> {
|
impl<E: Extension> QWrite for MkCalendar<E> {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let start = ctx.create_cal_element("mkcalendar");
|
let start = xml.create_cal_element("mkcalendar");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
self.0.write(xml, ctx.child()).await?;
|
self.0.qwrite(xml).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for MkCalendarResponse<C> {
|
impl<E: Extension> QWrite for MkCalendarResponse<E> {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let start = ctx.create_cal_element("mkcalendar-response");
|
let start = xml.create_cal_element("mkcalendar-response");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
for propstat in self.0.iter() {
|
for propstat in self.0.iter() {
|
||||||
propstat.write(xml, ctx.child()).await?;
|
propstat.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------- REPORT METHOD -------------------------------------
|
// ----------------------- REPORT METHOD -------------------------------------
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CalendarQuery<C> {
|
impl<E: Extension> QWrite for CalendarQuery<E> {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let start = ctx.create_cal_element("calendar-query");
|
let start = xml.create_cal_element("calendar-query");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
if let Some(selector) = &self.selector {
|
if let Some(selector) = &self.selector {
|
||||||
selector.write(xml, ctx.child()).await?;
|
selector.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
self.filter.write(xml, ctx.child()).await?;
|
self.filter.qwrite(xml).await?;
|
||||||
if let Some(tz) = &self.timezone {
|
if let Some(tz) = &self.timezone {
|
||||||
tz.write(xml, ctx.child()).await?;
|
tz.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CalendarMultiget<C> {
|
impl<E: Extension> QWrite for CalendarMultiget<E> {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let start = ctx.create_cal_element("calendar-multiget");
|
let start = xml.create_cal_element("calendar-multiget");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
if let Some(selector) = &self.selector {
|
if let Some(selector) = &self.selector {
|
||||||
selector.write(xml, ctx.child()).await?;
|
selector.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
for href in self.href.iter() {
|
for href in self.href.iter() {
|
||||||
href.write(xml, ctx.child()).await?;
|
href.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for FreeBusyQuery {
|
impl QWrite for FreeBusyQuery {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let start = ctx.create_cal_element("free-busy-query");
|
let start = xml.create_cal_element("free-busy-query");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
self.0.write(xml, ctx.child()).await?;
|
self.0.qwrite(xml).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------- DAV::prop --------------------------------------
|
// -------------------------- DAV::prop --------------------------------------
|
||||||
impl<C: CalContext> QuickWritable<C> for PropertyRequest {
|
impl QWrite for PropertyRequest {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut atom = async |c| xml.write_event_async(Event::Empty(ctx.create_cal_element(c))).await;
|
let mut atom = async |c| {
|
||||||
|
let empty_tag = xml.create_cal_element(c);
|
||||||
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
};
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Self::CalendarDescription => atom("calendar-description").await,
|
Self::CalendarDescription => atom("calendar-description").await,
|
||||||
|
@ -148,128 +101,137 @@ impl<C: CalContext> QuickWritable<C> for PropertyRequest {
|
||||||
Self::MaxInstances => atom("max-instances").await,
|
Self::MaxInstances => atom("max-instances").await,
|
||||||
Self::MaxAttendeesPerInstance => atom("max-attendees-per-instance").await,
|
Self::MaxAttendeesPerInstance => atom("max-attendees-per-instance").await,
|
||||||
Self::SupportedCollationSet => atom("supported-collation-set").await,
|
Self::SupportedCollationSet => atom("supported-collation-set").await,
|
||||||
Self::CalendarData(req) => req.write(xml, ctx).await,
|
Self::CalendarData(req) => req.qwrite(xml).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<C: CalContext> QuickWritable<C> for Property {
|
impl QWrite for Property {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Self::CalendarDescription { lang, text } => {
|
Self::CalendarDescription { lang, text } => {
|
||||||
let mut start = ctx.create_cal_element("calendar-description");
|
let mut start = xml.create_cal_element("calendar-description");
|
||||||
if let Some(the_lang) = lang {
|
if let Some(the_lang) = lang {
|
||||||
start.push_attribute(("xml:lang", the_lang.as_str()));
|
start.push_attribute(("xml:lang", the_lang.as_str()));
|
||||||
}
|
}
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
xml.write_event_async(Event::Text(BytesText::new(text))).await?;
|
xml.q.write_event_async(Event::Text(BytesText::new(text))).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::CalendarTimezone(payload) => {
|
Self::CalendarTimezone(payload) => {
|
||||||
let start = ctx.create_cal_element("calendar-timezone");
|
let start = xml.create_cal_element("calendar-timezone");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
xml.write_event_async(Event::Text(BytesText::new(payload))).await?;
|
xml.q.write_event_async(Event::Text(BytesText::new(payload))).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::SupportedCalendarComponentSet(many_comp) => {
|
Self::SupportedCalendarComponentSet(many_comp) => {
|
||||||
let start = ctx.create_cal_element("supported-calendar-component-set");
|
let start = xml.create_cal_element("supported-calendar-component-set");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
for comp in many_comp.iter() {
|
for comp in many_comp.iter() {
|
||||||
comp.write(xml, ctx.child()).await?;
|
comp.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::SupportedCalendarData(many_mime) => {
|
Self::SupportedCalendarData(many_mime) => {
|
||||||
let start = ctx.create_cal_element("supported-calendar-data");
|
let start = xml.create_cal_element("supported-calendar-data");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
for mime in many_mime.iter() {
|
for mime in many_mime.iter() {
|
||||||
mime.write(xml, ctx.child()).await?;
|
mime.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::MaxResourceSize(bytes) => {
|
Self::MaxResourceSize(bytes) => {
|
||||||
let start = ctx.create_cal_element("max-resource-size");
|
let start = xml.create_cal_element("max-resource-size");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
xml.write_event_async(Event::Text(BytesText::new(bytes.to_string().as_str()))).await?;
|
xml.q.write_event_async(Event::Text(BytesText::new(bytes.to_string().as_str()))).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::MinDateTime(dt) => {
|
Self::MinDateTime(dt) => {
|
||||||
let start = ctx.create_cal_element("min-date-time");
|
let start = xml.create_cal_element("min-date-time");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
let dtstr = format!("{}", dt.format(ICAL_DATETIME_FMT));
|
let dtstr = format!("{}", dt.format(ICAL_DATETIME_FMT));
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
xml.write_event_async(Event::Text(BytesText::new(dtstr.as_str()))).await?;
|
xml.q.write_event_async(Event::Text(BytesText::new(dtstr.as_str()))).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::MaxDateTime(dt) => {
|
Self::MaxDateTime(dt) => {
|
||||||
let start = ctx.create_cal_element("max-date-time");
|
let start = xml.create_cal_element("max-date-time");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
let dtstr = format!("{}", dt.format(ICAL_DATETIME_FMT));
|
let dtstr = format!("{}", dt.format(ICAL_DATETIME_FMT));
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
xml.write_event_async(Event::Text(BytesText::new(dtstr.as_str()))).await?;
|
xml.q.write_event_async(Event::Text(BytesText::new(dtstr.as_str()))).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::MaxInstances(count) => {
|
Self::MaxInstances(count) => {
|
||||||
let start = ctx.create_cal_element("max-instances");
|
let start = xml.create_cal_element("max-instances");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
xml.write_event_async(Event::Text(BytesText::new(count.to_string().as_str()))).await?;
|
xml.q.write_event_async(Event::Text(BytesText::new(count.to_string().as_str()))).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::MaxAttendeesPerInstance(count) => {
|
Self::MaxAttendeesPerInstance(count) => {
|
||||||
let start = ctx.create_cal_element("max-attendees-per-instance");
|
let start = xml.create_cal_element("max-attendees-per-instance");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
xml.write_event_async(Event::Text(BytesText::new(count.to_string().as_str()))).await?;
|
xml.q.write_event_async(Event::Text(BytesText::new(count.to_string().as_str()))).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::SupportedCollationSet(many_collations) => {
|
Self::SupportedCollationSet(many_collations) => {
|
||||||
let start = ctx.create_cal_element("supported-collation-set");
|
let start = xml.create_cal_element("supported-collation-set");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
for collation in many_collations.iter() {
|
for collation in many_collations.iter() {
|
||||||
collation.write(xml, ctx.child()).await?;
|
collation.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::CalendarData(inner) => inner.write(xml, ctx).await,
|
Self::CalendarData(inner) => inner.qwrite(xml).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------- DAV::resourcetype ----------------------------------
|
// ---------------------- DAV::resourcetype ----------------------------------
|
||||||
impl<C: CalContext> QuickWritable<C> for ResourceType {
|
impl QWrite for ResourceType {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Self::Calendar => xml.write_event_async(Event::Empty(ctx.create_dav_element("calendar"))).await,
|
Self::Calendar => {
|
||||||
|
let empty_tag = xml.create_dav_element("calendar");
|
||||||
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------- DAV::error ------------------------------------
|
// --------------------------- DAV::error ------------------------------------
|
||||||
impl<C: CalContext> QuickWritable<C> for Violation {
|
impl QWrite for Violation {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut atom = async |c| xml.write_event_async(Event::Empty(ctx.create_cal_element(c))).await;
|
let mut atom = async |c| {
|
||||||
|
let empty_tag = xml.create_cal_element(c);
|
||||||
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
};
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
//@FIXME
|
//@FIXME
|
||||||
// DAV elements, should not be here but in RFC3744 on ACLs
|
// DAV elements, should not be here but in RFC3744 on ACLs
|
||||||
// (we do not use atom as this error is in the DAV namespace, not the caldav one)
|
// (we do not use atom as this error is in the DAV namespace, not the caldav one)
|
||||||
Self::NeedPrivileges => xml.write_event_async(Event::Empty(ctx.create_dav_element("need-privileges"))).await,
|
Self::NeedPrivileges => {
|
||||||
|
let empty_tag = xml.create_dav_element("need-privileges");
|
||||||
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
},
|
||||||
|
|
||||||
// Regular CalDAV errors
|
// Regular CalDAV errors
|
||||||
Self::ResourceMustBeNull => atom("resource-must-be-null").await,
|
Self::ResourceMustBeNull => atom("resource-must-be-null").await,
|
||||||
|
@ -280,12 +242,12 @@ impl<C: CalContext> QuickWritable<C> for Violation {
|
||||||
Self::ValidCalendarObjectResource => atom("valid-calendar-object-resource").await,
|
Self::ValidCalendarObjectResource => atom("valid-calendar-object-resource").await,
|
||||||
Self::SupportedCalendarComponent => atom("supported-calendar-component").await,
|
Self::SupportedCalendarComponent => atom("supported-calendar-component").await,
|
||||||
Self::NoUidConflict(href) => {
|
Self::NoUidConflict(href) => {
|
||||||
let start = ctx.create_cal_element("no-uid-conflict");
|
let start = xml.create_cal_element("no-uid-conflict");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
href.write(xml, ctx.child()).await?;
|
href.qwrite(xml).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::MaxResourceSize => atom("max-resource-size").await,
|
Self::MaxResourceSize => atom("max-resource-size").await,
|
||||||
Self::MinDateTime => atom("min-date-time").await,
|
Self::MinDateTime => atom("min-date-time").await,
|
||||||
|
@ -294,20 +256,20 @@ impl<C: CalContext> QuickWritable<C> for Violation {
|
||||||
Self::MaxAttendeesPerInstance => atom("max-attendees-per-instance").await,
|
Self::MaxAttendeesPerInstance => atom("max-attendees-per-instance").await,
|
||||||
Self::ValidFilter => atom("valid-filter").await,
|
Self::ValidFilter => atom("valid-filter").await,
|
||||||
Self::SupportedFilter { comp, prop, param } => {
|
Self::SupportedFilter { comp, prop, param } => {
|
||||||
let start = ctx.create_cal_element("supported-filter");
|
let start = xml.create_cal_element("supported-filter");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
for comp_item in comp.iter() {
|
for comp_item in comp.iter() {
|
||||||
comp_item.write(xml, ctx.child()).await?;
|
comp_item.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
for prop_item in prop.iter() {
|
for prop_item in prop.iter() {
|
||||||
prop_item.write(xml, ctx.child()).await?;
|
prop_item.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
for param_item in param.iter() {
|
for param_item in param.iter() {
|
||||||
param_item.write(xml, ctx.child()).await?;
|
param_item.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
Self::NumberOfMatchesWithinLimits => atom("number-of-matches-within-limits").await,
|
Self::NumberOfMatchesWithinLimits => atom("number-of-matches-within-limits").await,
|
||||||
}
|
}
|
||||||
|
@ -316,112 +278,115 @@ impl<C: CalContext> QuickWritable<C> for Violation {
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------- Inner XML ------------------------------------
|
// ---------------------------- Inner XML ------------------------------------
|
||||||
impl<C: CalContext> QuickWritable<C> for SupportedCollation {
|
impl QWrite for SupportedCollation {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let start = ctx.create_cal_element("supported-collation");
|
let start = xml.create_cal_element("supported-collation");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
self.0.write(xml, ctx.child()).await?;
|
self.0.qwrite(xml).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for Collation {
|
impl QWrite for Collation {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let col = match self {
|
let col = match self {
|
||||||
Self::AsciiCaseMap => "i;ascii-casemap",
|
Self::AsciiCaseMap => "i;ascii-casemap",
|
||||||
Self::Octet => "i;octet",
|
Self::Octet => "i;octet",
|
||||||
Self::Unknown(v) => v.as_str(),
|
Self::Unknown(v) => v.as_str(),
|
||||||
};
|
};
|
||||||
|
|
||||||
xml.write_event_async(Event::Text(BytesText::new(col))).await
|
xml.q.write_event_async(Event::Text(BytesText::new(col))).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CalendarDataPayload {
|
impl QWrite for CalendarDataPayload {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut start = ctx.create_cal_element("calendar-data");
|
let mut start = xml.create_cal_element("calendar-data");
|
||||||
if let Some(mime) = &self.mime {
|
if let Some(mime) = &self.mime {
|
||||||
start.push_attribute(("content-type", mime.content_type.as_str()));
|
start.push_attribute(("content-type", mime.content_type.as_str()));
|
||||||
start.push_attribute(("version", mime.version.as_str()));
|
start.push_attribute(("version", mime.version.as_str()));
|
||||||
}
|
}
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
xml.write_event_async(Event::Text(BytesText::new(self.payload.as_str()))).await?;
|
xml.q.write_event_async(Event::Text(BytesText::new(self.payload.as_str()))).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CalendarDataRequest {
|
impl QWrite for CalendarDataRequest {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut start = ctx.create_cal_element("calendar-data");
|
let mut start = xml.create_cal_element("calendar-data");
|
||||||
if let Some(mime) = &self.mime {
|
if let Some(mime) = &self.mime {
|
||||||
start.push_attribute(("content-type", mime.content_type.as_str()));
|
start.push_attribute(("content-type", mime.content_type.as_str()));
|
||||||
start.push_attribute(("version", mime.version.as_str()));
|
start.push_attribute(("version", mime.version.as_str()));
|
||||||
}
|
}
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
if let Some(comp) = &self.comp {
|
if let Some(comp) = &self.comp {
|
||||||
comp.write(xml, ctx.child()).await?;
|
comp.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
if let Some(recurrence) = &self.recurrence {
|
if let Some(recurrence) = &self.recurrence {
|
||||||
recurrence.write(xml, ctx.child()).await?;
|
recurrence.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
if let Some(freebusy) = &self.limit_freebusy_set {
|
if let Some(freebusy) = &self.limit_freebusy_set {
|
||||||
freebusy.write(xml, ctx.child()).await?;
|
freebusy.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CalendarDataEmpty {
|
impl QWrite for CalendarDataEmpty {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut empty = ctx.create_cal_element("calendar-data");
|
let mut empty = xml.create_cal_element("calendar-data");
|
||||||
if let Some(mime) = &self.0 {
|
if let Some(mime) = &self.0 {
|
||||||
empty.push_attribute(("content-type", mime.content_type.as_str()));
|
empty.push_attribute(("content-type", mime.content_type.as_str()));
|
||||||
empty.push_attribute(("version", mime.version.as_str()));
|
empty.push_attribute(("version", mime.version.as_str()));
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::Empty(empty)).await
|
xml.q.write_event_async(Event::Empty(empty)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for Comp {
|
impl QWrite for Comp {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut start = ctx.create_cal_element("comp");
|
let mut start = xml.create_cal_element("comp");
|
||||||
start.push_attribute(("name", self.name.as_str()));
|
start.push_attribute(("name", self.name.as_str()));
|
||||||
match &self.additional_rules {
|
match &self.additional_rules {
|
||||||
None => xml.write_event_async(Event::Empty(start)).await,
|
None => xml.q.write_event_async(Event::Empty(start)).await,
|
||||||
Some(rules) => {
|
Some(rules) => {
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
rules.prop_kind.write(xml, ctx.child()).await?;
|
rules.prop_kind.qwrite(xml).await?;
|
||||||
rules.comp_kind.write(xml, ctx.child()).await?;
|
rules.comp_kind.qwrite(xml).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CompSupport {
|
impl QWrite for CompSupport {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut empty = ctx.create_cal_element("comp");
|
let mut empty = xml.create_cal_element("comp");
|
||||||
empty.push_attribute(("name", self.0.as_str()));
|
empty.push_attribute(("name", self.0.as_str()));
|
||||||
xml.write_event_async(Event::Empty(empty)).await
|
xml.q.write_event_async(Event::Empty(empty)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CompKind {
|
impl QWrite for CompKind {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Self::AllComp => xml.write_event_async(Event::Empty(ctx.create_cal_element("allcomp"))).await,
|
Self::AllComp => {
|
||||||
|
let empty_tag = xml.create_cal_element("allcomp");
|
||||||
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
},
|
||||||
Self::Comp(many_comp) => {
|
Self::Comp(many_comp) => {
|
||||||
for comp in many_comp.iter() {
|
for comp in many_comp.iter() {
|
||||||
// Required: recursion in an async fn requires boxing
|
// Required: recursion in an async fn requires boxing
|
||||||
// rustc --explain E0733
|
// rustc --explain E0733
|
||||||
Box::pin(comp.write(xml, ctx.child())).await?;
|
Box::pin(comp.qwrite(xml)).await?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -429,13 +394,16 @@ impl<C: CalContext> QuickWritable<C> for CompKind {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for PropKind {
|
impl QWrite for PropKind {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Self::AllProp => xml.write_event_async(Event::Empty(ctx.create_cal_element("allprop"))).await,
|
Self::AllProp => {
|
||||||
|
let empty_tag = xml.create_cal_element("allprop");
|
||||||
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
},
|
||||||
Self::Prop(many_prop) => {
|
Self::Prop(many_prop) => {
|
||||||
for prop in many_prop.iter() {
|
for prop in many_prop.iter() {
|
||||||
prop.write(xml, ctx.child()).await?;
|
prop.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -443,163 +411,175 @@ impl<C: CalContext> QuickWritable<C> for PropKind {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CalProp {
|
impl QWrite for CalProp {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut empty = ctx.create_cal_element("prop");
|
let mut empty = xml.create_cal_element("prop");
|
||||||
empty.push_attribute(("name", self.name.0.as_str()));
|
empty.push_attribute(("name", self.name.0.as_str()));
|
||||||
match self.novalue {
|
match self.novalue {
|
||||||
None => (),
|
None => (),
|
||||||
Some(true) => empty.push_attribute(("novalue", "yes")),
|
Some(true) => empty.push_attribute(("novalue", "yes")),
|
||||||
Some(false) => empty.push_attribute(("novalue", "no")),
|
Some(false) => empty.push_attribute(("novalue", "no")),
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::Empty(empty)).await
|
xml.q.write_event_async(Event::Empty(empty)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for RecurrenceModifier {
|
impl QWrite for RecurrenceModifier {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Self::Expand(exp) => exp.write(xml, ctx).await,
|
Self::Expand(exp) => exp.qwrite(xml).await,
|
||||||
Self::LimitRecurrenceSet(lrs) => lrs.write(xml, ctx).await,
|
Self::LimitRecurrenceSet(lrs) => lrs.qwrite(xml).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for Expand {
|
impl QWrite for Expand {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut empty = ctx.create_cal_element("expand");
|
let mut empty = xml.create_cal_element("expand");
|
||||||
empty.push_attribute(("start", format!("{}", self.0.format(ICAL_DATETIME_FMT)).as_str()));
|
empty.push_attribute(("start", format!("{}", self.0.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
empty.push_attribute(("end", format!("{}", self.1.format(ICAL_DATETIME_FMT)).as_str()));
|
empty.push_attribute(("end", format!("{}", self.1.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
xml.write_event_async(Event::Empty(empty)).await
|
xml.q.write_event_async(Event::Empty(empty)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for LimitRecurrenceSet {
|
impl QWrite for LimitRecurrenceSet {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut empty = ctx.create_cal_element("limit-recurrence-set");
|
let mut empty = xml.create_cal_element("limit-recurrence-set");
|
||||||
empty.push_attribute(("start", format!("{}", self.0.format(ICAL_DATETIME_FMT)).as_str()));
|
empty.push_attribute(("start", format!("{}", self.0.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
empty.push_attribute(("end", format!("{}", self.1.format(ICAL_DATETIME_FMT)).as_str()));
|
empty.push_attribute(("end", format!("{}", self.1.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
xml.write_event_async(Event::Empty(empty)).await
|
xml.q.write_event_async(Event::Empty(empty)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for LimitFreebusySet {
|
impl QWrite for LimitFreebusySet {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut empty = ctx.create_cal_element("limit-freebusy-set");
|
let mut empty = xml.create_cal_element("limit-freebusy-set");
|
||||||
empty.push_attribute(("start", format!("{}", self.0.format(ICAL_DATETIME_FMT)).as_str()));
|
empty.push_attribute(("start", format!("{}", self.0.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
empty.push_attribute(("end", format!("{}", self.1.format(ICAL_DATETIME_FMT)).as_str()));
|
empty.push_attribute(("end", format!("{}", self.1.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
xml.write_event_async(Event::Empty(empty)).await
|
xml.q.write_event_async(Event::Empty(empty)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CalendarSelector<C> {
|
impl<E: Extension> QWrite for CalendarSelector<E> {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Self::AllProp => xml.write_event_async(Event::Empty(ctx.create_dav_element("allprop"))).await,
|
Self::AllProp => {
|
||||||
Self::PropName => xml.write_event_async(Event::Empty(ctx.create_dav_element("propname"))).await,
|
let empty_tag = xml.create_dav_element("allprop");
|
||||||
Self::Prop(prop) => prop.write(xml, ctx).await,
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
},
|
||||||
|
Self::PropName => {
|
||||||
|
let empty_tag = xml.create_dav_element("propname");
|
||||||
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
},
|
||||||
|
Self::Prop(prop) => prop.qwrite(xml).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CompFilter {
|
impl QWrite for CompFilter {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut start = ctx.create_cal_element("comp-filter");
|
let mut start = xml.create_cal_element("comp-filter");
|
||||||
start.push_attribute(("name", self.name.as_str()));
|
start.push_attribute(("name", self.name.as_str()));
|
||||||
|
|
||||||
match &self.additional_rules {
|
match &self.additional_rules {
|
||||||
None => xml.write_event_async(Event::Empty(start)).await,
|
None => xml.q.write_event_async(Event::Empty(start)).await,
|
||||||
Some(rules) => {
|
Some(rules) => {
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
rules.write(xml, ctx.child()).await?;
|
rules.qwrite(xml).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CompFilterRules {
|
impl QWrite for CompFilterRules {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Self::IsNotDefined => xml.write_event_async(Event::Empty(ctx.create_dav_element("is-not-defined"))).await,
|
Self::IsNotDefined => {
|
||||||
Self::Matches(cfm) => cfm.write(xml, ctx).await,
|
let empty_tag = xml.create_dav_element("is-not-defined");
|
||||||
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
},
|
||||||
|
Self::Matches(cfm) => cfm.qwrite(xml).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CompFilterMatch {
|
impl QWrite for CompFilterMatch {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
if let Some(time_range) = &self.time_range {
|
if let Some(time_range) = &self.time_range {
|
||||||
time_range.write(xml, ctx.child()).await?;
|
time_range.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
for prop_item in self.prop_filter.iter() {
|
for prop_item in self.prop_filter.iter() {
|
||||||
prop_item.write(xml, ctx.child()).await?;
|
prop_item.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
for comp_item in self.comp_filter.iter() {
|
for comp_item in self.comp_filter.iter() {
|
||||||
// Required: recursion in an async fn requires boxing
|
// Required: recursion in an async fn requires boxing
|
||||||
// rustc --explain E0733
|
// rustc --explain E0733
|
||||||
Box::pin(comp_item.write(xml, ctx.child())).await?;
|
Box::pin(comp_item.qwrite(xml)).await?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for PropFilter {
|
impl QWrite for PropFilter {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut start = ctx.create_cal_element("prop-filter");
|
let mut start = xml.create_cal_element("prop-filter");
|
||||||
start.push_attribute(("name", self.name.as_str()));
|
start.push_attribute(("name", self.name.as_str()));
|
||||||
|
|
||||||
match &self.additional_rules {
|
match &self.additional_rules {
|
||||||
None => xml.write_event_async(Event::Empty(start)).await,
|
None => xml.q.write_event_async(Event::Empty(start.clone())).await,
|
||||||
Some(rules) => {
|
Some(rules) => {
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
rules.write(xml, ctx.child()).await?;
|
rules.qwrite(xml).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for PropFilterRules {
|
impl QWrite for PropFilterRules {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Self::IsNotDefined => xml.write_event_async(Event::Empty(ctx.create_dav_element("is-not-defined"))).await,
|
Self::IsNotDefined => {
|
||||||
Self::Match(prop_match) => prop_match.write(xml, ctx).await,
|
let empty_tag = xml.create_dav_element("is-not-defined");
|
||||||
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
},
|
||||||
|
Self::Match(prop_match) => prop_match.qwrite(xml).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for PropFilterMatch {
|
impl QWrite for PropFilterMatch {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
if let Some(time_range) = &self.time_range {
|
if let Some(time_range) = &self.time_range {
|
||||||
time_range.write(xml, ctx.child()).await?;
|
time_range.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
if let Some(time_or_text) = &self.time_or_text {
|
if let Some(time_or_text) = &self.time_or_text {
|
||||||
time_or_text.write(xml, ctx.child()).await?;
|
time_or_text.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
for param_item in self.param_filter.iter() {
|
for param_item in self.param_filter.iter() {
|
||||||
param_item.write(xml, ctx.child()).await?;
|
param_item.qwrite(xml).await?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for TimeOrText {
|
impl QWrite for TimeOrText {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Self::Time(time) => time.write(xml, ctx).await,
|
Self::Time(time) => time.qwrite(xml).await,
|
||||||
Self::Text(txt) => txt.write(xml, ctx).await,
|
Self::Text(txt) => txt.qwrite(xml).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for TextMatch {
|
impl QWrite for TextMatch {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut start = ctx.create_cal_element("text-match");
|
let mut start = xml.create_cal_element("text-match");
|
||||||
if let Some(collation) = &self.collation {
|
if let Some(collation) = &self.collation {
|
||||||
start.push_attribute(("collation", collation.as_str()));
|
start.push_attribute(("collation", collation.as_str()));
|
||||||
}
|
}
|
||||||
|
@ -610,63 +590,66 @@ impl<C: CalContext> QuickWritable<C> for TextMatch {
|
||||||
}
|
}
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
xml.write_event_async(Event::Text(BytesText::new(self.text.as_str()))).await?;
|
xml.q.write_event_async(Event::Text(BytesText::new(self.text.as_str()))).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for ParamFilter {
|
impl QWrite for ParamFilter {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut start = ctx.create_cal_element("param-filter");
|
let mut start = xml.create_cal_element("param-filter");
|
||||||
start.push_attribute(("name", self.name.as_str()));
|
start.push_attribute(("name", self.name.as_str()));
|
||||||
|
|
||||||
match &self.additional_rules {
|
match &self.additional_rules {
|
||||||
None => xml.write_event_async(Event::Empty(start)).await,
|
None => xml.q.write_event_async(Event::Empty(start)).await,
|
||||||
Some(rules) => {
|
Some(rules) => {
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
rules.write(xml, ctx.child()).await?;
|
rules.qwrite(xml).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for ParamFilterMatch {
|
impl QWrite for ParamFilterMatch {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Self::IsNotDefined => xml.write_event_async(Event::Empty(ctx.create_dav_element("is-not-defined"))).await,
|
Self::IsNotDefined => {
|
||||||
Self::Match(tm) => tm.write(xml, ctx).await,
|
let empty_tag = xml.create_dav_element("is-not-defined");
|
||||||
|
xml.q.write_event_async(Event::Empty(empty_tag)).await
|
||||||
|
},
|
||||||
|
Self::Match(tm) => tm.qwrite(xml).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for TimeZone {
|
impl QWrite for TimeZone {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut start = ctx.create_cal_element("timezone");
|
let mut start = xml.create_cal_element("timezone");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
xml.write_event_async(Event::Text(BytesText::new(self.0.as_str()))).await?;
|
xml.q.write_event_async(Event::Text(BytesText::new(self.0.as_str()))).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for Filter {
|
impl QWrite for Filter {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut start = ctx.create_cal_element("filter");
|
let mut start = xml.create_cal_element("filter");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
|
||||||
xml.write_event_async(Event::Start(start.clone())).await?;
|
xml.q.write_event_async(Event::Start(start.clone())).await?;
|
||||||
self.0.write(xml, ctx.child()).await?;
|
self.0.qwrite(xml).await?;
|
||||||
xml.write_event_async(Event::End(end)).await
|
xml.q.write_event_async(Event::End(end)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for TimeRange {
|
impl QWrite for TimeRange {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let mut empty = ctx.create_cal_element("time-range");
|
let mut empty = xml.create_cal_element("time-range");
|
||||||
match self {
|
match self {
|
||||||
Self::OnlyStart(start) => empty.push_attribute(("start", format!("{}", start.format(ICAL_DATETIME_FMT)).as_str())),
|
Self::OnlyStart(start) => empty.push_attribute(("start", format!("{}", start.format(ICAL_DATETIME_FMT)).as_str())),
|
||||||
Self::OnlyEnd(end) => empty.push_attribute(("end", format!("{}", end.format(ICAL_DATETIME_FMT)).as_str())),
|
Self::OnlyEnd(end) => empty.push_attribute(("end", format!("{}", end.format(ICAL_DATETIME_FMT)).as_str())),
|
||||||
|
@ -675,11 +658,11 @@ impl<C: CalContext> QuickWritable<C> for TimeRange {
|
||||||
empty.push_attribute(("end", format!("{}", end.format(ICAL_DATETIME_FMT)).as_str()));
|
empty.push_attribute(("end", format!("{}", end.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::Empty(empty)).await
|
xml.q.write_event_async(Event::Empty(empty)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
/*
|
|
||||||
use chrono::{DateTime,Utc};
|
use chrono::{DateTime,Utc};
|
||||||
use super::types as dav;
|
use super::types as dav;
|
||||||
|
|
||||||
|
@ -647,7 +646,7 @@ pub enum Violation {
|
||||||
/// making use of the same UID property value in the DAV:href element;
|
/// making use of the same UID property value in the DAV:href element;
|
||||||
///
|
///
|
||||||
/// <!ELEMENT no-uid-conflict (DAV:href)>
|
/// <!ELEMENT no-uid-conflict (DAV:href)>
|
||||||
NoUidConflict(Dav::Href),
|
NoUidConflict(dav::Href),
|
||||||
|
|
||||||
/// (CALDAV:max-resource-size): The resource submitted in the PUT
|
/// (CALDAV:max-resource-size): The resource submitted in the PUT
|
||||||
/// request, or targeted by a COPY or MOVE request, MUST have an octet
|
/// request, or targeted by a COPY or MOVE request, MUST have an octet
|
||||||
|
@ -1394,4 +1393,4 @@ impl Collation {
|
||||||
Self::Unknown(c) => c.as_str(),
|
Self::Unknown(c) => c.as_str(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
Loading…
Reference in a new issue