aboutsummaryrefslogtreecommitdiff
path: root/src/dav/encoder.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-03-01 10:29:16 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-03-01 10:29:16 +0100
commitc52a6591512825d297b0636cc228ee0915974404 (patch)
tree9b415d208ab8d246b589f80e4b91243f69a4d726 /src/dav/encoder.rs
parent929a185f371a7f369c4437d47b5c9e9f414678cf (diff)
downloadaerogramme-c52a6591512825d297b0636cc228ee0915974404.tar.gz
aerogramme-c52a6591512825d297b0636cc228ee0915974404.zip
hook resource type
Diffstat (limited to 'src/dav/encoder.rs')
-rw-r--r--src/dav/encoder.rs14
1 files changed, 11 insertions, 3 deletions
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!();
}