From 33a02ff695c57fe88d394ad4d556bb390934ccd6 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 29 Feb 2024 23:02:02 +0100 Subject: WIP encoder --- src/dav/encoder.rs | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'src/dav/encoder.rs') 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> QuickWritable for ResponseDescription { impl> QuickWritable for Location { async fn write(&self, xml: &mut Writer, 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> QuickWritable for PropStat { async fn write(&self, xml: &mut Writer, 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> QuickWritable for Prop { + async fn write(&self, xml: &mut Writer, 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> QuickWritable for Property { + async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { + use Property::*; + match self { + CreationDate(date) => unimplemented!(), + DisplayName(name) => unimplemented!(), + //@FIXME not finished + _ => unimplemented!(), + }; + Ok(()) + } +} + + + impl> QuickWritable for Error { async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { let start = ctx.create_dav_element("error"); -- cgit v1.2.3