aboutsummaryrefslogtreecommitdiff
path: root/src/dav/calencoder.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-03-01 08:32:02 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-03-01 08:32:02 +0100
commite88e448179239fcc41aa03efcbfb2cc2ab0c922e (patch)
treea3677021f62716d931f130e3e477289e5a428619 /src/dav/calencoder.rs
parent33a02ff695c57fe88d394ad4d556bb390934ccd6 (diff)
downloadaerogramme-e88e448179239fcc41aa03efcbfb2cc2ab0c922e.tar.gz
aerogramme-e88e448179239fcc41aa03efcbfb2cc2ab0c922e.zip
Simplify code
Diffstat (limited to 'src/dav/calencoder.rs')
-rw-r--r--src/dav/calencoder.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/dav/calencoder.rs b/src/dav/calencoder.rs
index aabdf36..378d2bd 100644
--- a/src/dav/calencoder.rs
+++ b/src/dav/calencoder.rs
@@ -8,10 +8,7 @@ use quick_xml::writer::{ElementWriter, Writer};
use quick_xml::name::PrefixDeclaration;
use tokio::io::AsyncWrite;
-pub struct CalCtx {
- root: bool
-}
-impl Context<CalExtension> for CalCtx {
+impl Context for CalExtension {
fn child(&self) -> Self {
Self { root: false }
}
@@ -23,7 +20,8 @@ impl Context<CalExtension> for CalCtx {
err.write(xml, self.child()).await
}
}
-impl CalCtx {
+
+impl CalExtension {
fn create_ns_element(&self, ns: &str, name: &str) -> BytesStart {
let mut start = BytesStart::new(format!("{}:{}", ns, name));
if self.root {
@@ -37,8 +35,8 @@ impl CalCtx {
}
}
-impl QuickWritable<CalExtension, CalCtx> for Violation {
- async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: CalCtx) -> Result<(), QError> {
+impl QuickWritable<CalExtension> for Violation {
+ async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: CalExtension) -> Result<(), QError> {
match self {
Self::SupportedFilter => {
let start = ctx.create_cal_element("supported-filter");
@@ -70,11 +68,11 @@ mod tests {
let mut tokio_buffer = tokio::io::BufWriter::new(&mut buffer);
let mut writer = Writer::new_with_indent(&mut tokio_buffer, b' ', 4);
- let res: Error<CalExtension> = Error(vec![
+ let res = Error(vec![
DavViolation::Extension(Violation::SupportedFilter),
]);
- res.write(&mut writer, CalCtx{ root: true }).await.expect("xml serialization");
+ res.write(&mut writer, CalExtension { root: true }).await.expect("xml serialization");
tokio_buffer.flush().await.expect("tokio buffer flush");
let expected = r#"<D:error xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">