aboutsummaryrefslogtreecommitdiff
path: root/src/dav/encoder.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-02-29 23:02:02 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-02-29 23:02:02 +0100
commit33a02ff695c57fe88d394ad4d556bb390934ccd6 (patch)
tree2d629bca27a630528327fae6eeaa00dc9f6f5bfd /src/dav/encoder.rs
parentfadadffc927015948d38824ea1d70810392182b9 (diff)
downloadaerogramme-33a02ff695c57fe88d394ad4d556bb390934ccd6.tar.gz
aerogramme-33a02ff695c57fe88d394ad4d556bb390934ccd6.zip
WIP encoder
Diffstat (limited to 'src/dav/encoder.rs')
-rw-r--r--src/dav/encoder.rs56
1 files changed, 54 insertions, 2 deletions
diff --git a/src/dav/encoder.rs b/src/dav/encoder.rs
index e77e072..2c9fdac 100644
--- a/src/dav/encoder.rs
+++ b/src/dav/encoder.rs
@@ -149,16 +149,68 @@ impl<E: Extension, C: Context<E>> QuickWritable<E,C> for ResponseDescription {
impl<E: Extension, C: Context<E>> QuickWritable<E,C> for Location {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
- unimplemented!();
+ let start = ctx.create_dav_element("location");
+ 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?;
+
+ Ok(())
}
}
impl<E: Extension, C: Context<E>> QuickWritable<E,C> for PropStat<E> {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
- unimplemented!();
+ let start = ctx.create_dav_element("propstat");
+ let end = start.to_end();
+
+ xml.write_event_async(Event::Start(start.clone())).await?;
+ self.prop.write(xml, ctx.child()).await?;
+ self.status.write(xml, ctx.child()).await?;
+ if let Some(error) = &self.error {
+ error.write(xml, ctx.child()).await?;
+ }
+ if let Some(description) = &self.responsedescription {
+ description.write(xml, ctx.child()).await?;
+ }
+ xml.write_event_async(Event::End(end)).await?;
+
+ Ok(())
}
}
+impl<E: Extension, C: Context<E>> QuickWritable<E,C> for Prop<E> {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ let start = ctx.create_dav_element("prop");
+ let end = start.to_end();
+
+ xml.write_event_async(Event::Start(start.clone())).await?;
+ for property in &self.0 {
+ property.write(xml, ctx.child()).await?;
+ }
+ xml.write_event_async(Event::End(end)).await?;
+
+ Ok(())
+ }
+}
+
+
+impl<E: Extension, C: Context<E>> QuickWritable<E,C> for Property<E> {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
+ use Property::*;
+ match self {
+ CreationDate(date) => unimplemented!(),
+ DisplayName(name) => unimplemented!(),
+ //@FIXME not finished
+ _ => unimplemented!(),
+ };
+ Ok(())
+ }
+}
+
+
+
impl<E: Extension, C: Context<E>> QuickWritable<E,C> for Error<E> {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
let start = ctx.create_dav_element("error");