aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-03-02 16:52:52 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-03-02 16:52:52 +0100
commit9514af8f525a3c70075274f5c4ca95ac03eecedf (patch)
tree3d4d44ba4c5c43ecdc4af5884f58341bbc066d94
parentf1861e3f1265a47513779bd251298d034a9011a0 (diff)
downloadaerogramme-9514af8f525a3c70075274f5c4ca95ac03eecedf.tar.gz
aerogramme-9514af8f525a3c70075274f5c4ca95ac03eecedf.zip
Calendar skeleton
-rw-r--r--src/dav/calencoder.rs266
-rw-r--r--src/dav/caltypes.rs4
2 files changed, 257 insertions, 13 deletions
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<C: CalContext> QuickWritable<C> for MkCalendar<C> {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for MkCalendarResponse<C> {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+// ----------------------- REPORT METHOD -------------------------------------
+
+impl<C: CalContext> QuickWritable<C> for CalendarQuery<C> {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for CalendarMultiget<C> {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for FreeBusyQuery {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+// -------------------------- DAV::prop --------------------------------------
+impl<C: CalContext> QuickWritable<C> for Property {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+impl<C: CalContext> QuickWritable<C> for PropertyRequest {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+// ---------------------- DAV::resourcetype ----------------------------------
+impl<C: CalContext> QuickWritable<C> for ResourceType {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ match self {
+ Self::Calendar => xml.write_event_async(Event::Empty(ctx.create_dav_element("calendar"))).await,
+ }
}
}
-impl QuickWritable<CalExtension> for Violation {
- async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: CalExtension) -> Result<(), QError> {
+// --------------------------- DAV::error ------------------------------------
+impl<C: CalContext> QuickWritable<C> for Violation {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
match self {
Self::ResourceMustBeNull => {
let start = ctx.create_cal_element("resource-must-be-null");
@@ -61,26 +127,200 @@ impl QuickWritable<CalExtension> for Violation {
}
-impl QuickWritable<CalExtension> for Property {
- async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: CalExtension) -> Result<(), QError> {
+// ---------------------------- Inner XML ------------------------------------
+impl<C: CalContext> QuickWritable<C> for SupportedCollation {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
unimplemented!();
}
}
-impl QuickWritable<CalExtension> for PropertyRequest {
- async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: CalExtension) -> Result<(), QError> {
+impl<C: CalContext> QuickWritable<C> for Collation {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
unimplemented!();
}
}
-impl QuickWritable<CalExtension> for ResourceType {
- async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: CalExtension) -> Result<(), QError> {
- match self {
- Self::Calendar => xml.write_event_async(Event::Empty(ctx.create_dav_element("calendar"))).await,
- }
+impl<C: CalContext> QuickWritable<C> for CalendarDataPayload {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for CalendarDataRequest {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+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!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for Comp {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for CompSupport {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for CompKind {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for PropKind {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for CalProp {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for RecurrenceModifier {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for Expand {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for LimitRecurrenceSet {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for LimitFreebusySet {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for CalendarSelector<C> {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for CompFilter {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for CompFilterInner {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for CompFilterMatch {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for PropFilter {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for PropFilterInner {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for PropFilterMatch {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
}
}
+impl<C: CalContext> QuickWritable<C> for TimeOrText {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for TextMatch {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for ParamFilter {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for ParamFilterMatch {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for TimeZone {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for Filter {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for Component {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for ComponentProperty {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for PropertyParameter {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ unimplemented!();
+ }
+}
+
+impl<C: CalContext> QuickWritable<C> for TimeRange {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, 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<E: Dav::Extension>(Dav::Set<E>);
/// <!ELEMENT mkcol-response (propstat+)>
pub struct MkCalendarResponse<T: Dav::Extension>(Vec<Dav::PropStat<T>>);
+// --- (REPORT PART) ---
+
/// Name: calendar-query
///
/// Namespace: urn:ietf:params:xml:ns:caldav