aboutsummaryrefslogtreecommitdiff
path: root/src/dav/calencoder.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-02-29 22:32:07 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-02-29 22:32:07 +0100
commitfadadffc927015948d38824ea1d70810392182b9 (patch)
tree1a340148933f16b78984a693393029036091d789 /src/dav/calencoder.rs
parent1e3737a590e2b329afc2b5531cf4ae67fb48a571 (diff)
downloadaerogramme-fadadffc927015948d38824ea1d70810392182b9.tar.gz
aerogramme-fadadffc927015948d38824ea1d70810392182b9.zip
Fixed tests
Diffstat (limited to 'src/dav/calencoder.rs')
-rw-r--r--src/dav/calencoder.rs25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/dav/calencoder.rs b/src/dav/calencoder.rs
index 918083d..fbd696d 100644
--- a/src/dav/calencoder.rs
+++ b/src/dav/calencoder.rs
@@ -38,25 +38,34 @@ impl Context<CalExtension> for CalCtx {
Self { root: false }
}
fn create_dav_element(&self, name: &str) -> BytesStart {
- let mut start = BytesStart::new(format!("D:{}", name));
+ self.create_ns_element("D", name)
+ }
+
+ async fn hook_error(&self, err: &Violation, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
+ err.write(xml, self.child()).await
+ }
+}
+impl CalCtx {
+ fn create_ns_element(&self, ns: &str, name: &str) -> BytesStart {
+ let mut start = BytesStart::new(format!("{}:{}", ns, name));
if self.root {
start.push_attribute(("xmlns:D", "DAV:"));
start.push_attribute(("xmlns:C", "urn:ietf:params:xml:ns:caldav"));
}
start
}
-
- async fn hook_error(&self, err: &Violation, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
- err.write(xml, self.child()).await
+ fn create_cal_element(&self, name: &str) -> BytesStart {
+ self.create_ns_element("C", name)
}
}
impl QuickWritable<CalExtension, CalCtx> for Violation {
- async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, _ctx: CalCtx) -> Result<(), QError> {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: CalCtx) -> Result<(), QError> {
match self {
- Self::SupportedFilter => xml
- .create_element("supported-filter")
- .write_empty_async().await?,
+ Self::SupportedFilter => {
+ let start = ctx.create_cal_element("supported-filter");
+ xml.write_event_async(Event::Empty(start)).await?;
+ },
};
Ok(())
}