aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dav/calencoder.rs12
-rw-r--r--src/dav/caltypes.rs6
-rw-r--r--src/dav/encoder.rs14
3 files changed, 27 insertions, 5 deletions
diff --git a/src/dav/calencoder.rs b/src/dav/calencoder.rs
index 14b7903..fc380ac 100644
--- a/src/dav/calencoder.rs
+++ b/src/dav/calencoder.rs
@@ -23,6 +23,10 @@ impl Context for CalExtension {
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
+ }
}
impl CalExtension {
@@ -58,7 +62,13 @@ impl QuickWritable<CalExtension> for Property {
}
}
-
+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,
+ }
+ }
+}
#[cfg(test)]
mod tests {
diff --git a/src/dav/caltypes.rs b/src/dav/caltypes.rs
index a68936c..9e4cb47 100644
--- a/src/dav/caltypes.rs
+++ b/src/dav/caltypes.rs
@@ -8,7 +8,7 @@ impl Extension for CalExtension {
type Error = Violation;
type Property = Property;
type PropertyRequest = Property; //@FIXME
- type ResourceType = Property; //@FIXME
+ type ResourceType = ResourceType;
}
pub enum Violation {
@@ -34,3 +34,7 @@ pub enum Property {
CalendarDescription,
CalendarTimezone,
}
+
+pub enum ResourceType {
+ Calendar,
+}
diff --git a/src/dav/encoder.rs b/src/dav/encoder.rs
index 332c13a..72d815b 100644
--- a/src/dav/encoder.rs
+++ b/src/dav/encoder.rs
@@ -21,6 +21,7 @@ pub trait Context: Extension {
fn create_dav_element(&self, name: &str) -> BytesStart;
async fn hook_error(&self, err: &Self::Error, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError>;
async fn hook_property(&self, prop: &Self::Property, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError>;
+ async fn hook_resourcetype(&self, prop: &Self::ResourceType, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError>;
}
/// -------------- NoExtension Encoding Context
@@ -41,6 +42,9 @@ impl Context for NoExtension {
async fn hook_property(&self, prop: &Disabled, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
unreachable!();
}
+ async fn hook_resourcetype(&self, restype: &Disabled, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
+ unreachable!();
+ }
}
@@ -320,13 +324,17 @@ impl<C: Context> QuickWritable<C> for Property<C> {
}
}
-impl<C: Context> QuickWritable<C> for ActiveLock {
+impl<C: Context> QuickWritable<C> for ResourceType<C> {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
- unimplemented!();
+ match self {
+ Self::Collection => xml.write_event_async(Event::Empty(ctx.create_dav_element("collection"))).await?,
+ Self::Extension(inner) => ctx.hook_resourcetype(inner, xml).await?,
+ };
+ Ok(())
}
}
-impl<C: Context> QuickWritable<C> for ResourceType<C> {
+impl<C: Context> QuickWritable<C> for ActiveLock {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
unimplemented!();
}