aboutsummaryrefslogtreecommitdiff
path: root/aero-dav/src/calencoder.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-03-12 10:18:13 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-03-12 10:18:13 +0100
commit442433d70bf13b1641ec76077d9955f5d63ee965 (patch)
treeee48a3a3f579bcb0b14812cee24a45b9660966a5 /aero-dav/src/calencoder.rs
parent6d1f538091ca9445cdc0d72b051fa5090b6ec68a (diff)
downloadaerogramme-442433d70bf13b1641ec76077d9955f5d63ee965.tar.gz
aerogramme-442433d70bf13b1641ec76077d9955f5d63ee965.zip
fix parsing
Diffstat (limited to 'aero-dav/src/calencoder.rs')
-rw-r--r--aero-dav/src/calencoder.rs61
1 files changed, 28 insertions, 33 deletions
diff --git a/aero-dav/src/calencoder.rs b/aero-dav/src/calencoder.rs
index 6ad9f41..fff4d47 100644
--- a/aero-dav/src/calencoder.rs
+++ b/aero-dav/src/calencoder.rs
@@ -353,23 +353,21 @@ impl QWrite for CalendarDataEmpty {
}
}
-impl QWrite for CompInner {
- async fn qwrite(&self, _xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
- unreachable!();
- }
-}
-
impl QWrite for Comp {
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
let mut start = xml.create_cal_element("comp");
start.push_attribute(("name", self.name.as_str()));
- match &self.additional_rules {
- None => xml.q.write_event_async(Event::Empty(start)).await,
- Some(rules) => {
+ match (&self.prop_kind, &self.comp_kind) {
+ (None, None) => xml.q.write_event_async(Event::Empty(start)).await,
+ _ => {
let end = start.to_end();
xml.q.write_event_async(Event::Start(start.clone())).await?;
- rules.prop_kind.qwrite(xml).await?;
- rules.comp_kind.qwrite(xml).await?;
+ if let Some(prop_kind) = &self.prop_kind {
+ prop_kind.qwrite(xml).await?;
+ }
+ if let Some(comp_kind) = &self.comp_kind {
+ comp_kind.qwrite(xml).await?;
+ }
xml.q.write_event_async(Event::End(end)).await
},
}
@@ -721,39 +719,36 @@ mod tests {
mime: None,
comp: Some(Comp {
name: Component::VCalendar,
- additional_rules: Some(CompInner {
- prop_kind: PropKind::Prop(vec![
+ prop_kind: Some(PropKind::Prop(vec![
CalProp {
name: ComponentProperty("VERSION".into()),
novalue: None,
}
- ]),
- comp_kind: CompKind::Comp(vec![
+ ])),
+ comp_kind: Some(CompKind::Comp(vec![
Comp {
name: Component::VEvent,
- additional_rules: Some(CompInner {
- prop_kind: PropKind::Prop(vec![
- CalProp { name: ComponentProperty("SUMMARY".into()), novalue: None },
- CalProp { name: ComponentProperty("UID".into()), novalue: None },
- CalProp { name: ComponentProperty("DTSTART".into()), novalue: None },
- CalProp { name: ComponentProperty("DTEND".into()), novalue: None },
- CalProp { name: ComponentProperty("DURATION".into()), novalue: None },
- CalProp { name: ComponentProperty("RRULE".into()), novalue: None },
- CalProp { name: ComponentProperty("RDATE".into()), novalue: None },
- CalProp { name: ComponentProperty("EXRULE".into()), novalue: None },
- CalProp { name: ComponentProperty("EXDATE".into()), novalue: None },
- CalProp { name: ComponentProperty("RECURRENCE-ID".into()), novalue: None },
- ]),
- comp_kind: CompKind::Comp(vec![]),
- }),
+ prop_kind: Some(PropKind::Prop(vec![
+ CalProp { name: ComponentProperty("SUMMARY".into()), novalue: None },
+ CalProp { name: ComponentProperty("UID".into()), novalue: None },
+ CalProp { name: ComponentProperty("DTSTART".into()), novalue: None },
+ CalProp { name: ComponentProperty("DTEND".into()), novalue: None },
+ CalProp { name: ComponentProperty("DURATION".into()), novalue: None },
+ CalProp { name: ComponentProperty("RRULE".into()), novalue: None },
+ CalProp { name: ComponentProperty("RDATE".into()), novalue: None },
+ CalProp { name: ComponentProperty("EXRULE".into()), novalue: None },
+ CalProp { name: ComponentProperty("EXDATE".into()), novalue: None },
+ CalProp { name: ComponentProperty("RECURRENCE-ID".into()), novalue: None },
+ ])),
+ comp_kind: None,
},
Comp {
name: Component::VTimeZone,
- additional_rules: None,
+ prop_kind: None,
+ comp_kind: None,
}
- ]),
+ ])),
}),
- }),
recurrence: None,
limit_freebusy_set: None,
})),