diff --git a/src/dav/calencoder.rs b/src/dav/calencoder.rs index ca314f1..503d48b 100644 --- a/src/dav/calencoder.rs +++ b/src/dav/calencoder.rs @@ -593,19 +593,46 @@ impl QuickWritable for TimeOrText { impl QuickWritable for TextMatch { async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { - unimplemented!(); + let mut start = ctx.create_cal_element("text-match"); + if let Some(collation) = &self.collation { + start.push_attribute(("collation", collation.as_str())); + } + match self.negate_condition { + None => (), + Some(true) => start.push_attribute(("negate-condition", "yes")), + Some(false) => start.push_attribute(("negate-condition", "no")), + } + let end = start.to_end(); + + xml.write_event_async(Event::Start(start.clone())).await?; + xml.write_event_async(Event::Text(BytesText::new(self.text.as_str()))).await?; + xml.write_event_async(Event::End(end)).await } } impl QuickWritable for ParamFilter { async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { - unimplemented!(); + let mut start = ctx.create_cal_element("param-filter"); + start.push_attribute(("name", self.name.as_str())); + + match &self.additional_rules { + None => xml.write_event_async(Event::Empty(start)).await, + Some(rules) => { + let end = start.to_end(); + xml.write_event_async(Event::Start(start.clone())).await?; + rules.write(xml, ctx.child()).await?; + xml.write_event_async(Event::End(end)).await + } + } } } impl QuickWritable for ParamFilterMatch { async fn write(&self, xml: &mut Writer, ctx: C) -> Result<(), QError> { - unimplemented!(); + match self { + Self::IsNotDefined => xml.write_event_async(Event::Empty(ctx.create_dav_element("is-not-defined"))).await, + Self::Match(tm) => tm.write(xml, ctx).await, + } } } diff --git a/src/dav/caltypes.rs b/src/dav/caltypes.rs index e2ba490..5d30600 100644 --- a/src/dav/caltypes.rs +++ b/src/dav/caltypes.rs @@ -778,6 +778,15 @@ pub enum Collation { Octet, Unknown(String), } +impl Collation { + pub fn as_str<'a>(&'a self) -> &'a str { + match self { + Self::AsciiCaseMap => "i;ascii-casemap", + Self::Octet => "i;octet", + Self::Unknown(c) => c.as_str(), + } + } +} /// @@ -1261,8 +1270,8 @@ pub struct TextMatch { /// /// name value: a property parameter name (e.g., PARTSTAT) pub struct ParamFilter { - name: PropertyParameter, - inner: Option, + pub name: PropertyParameter, + pub additional_rules: Option, } pub enum ParamFilterMatch { IsNotDefined, @@ -1366,7 +1375,12 @@ impl Component { pub struct ComponentProperty(pub String); /// like PARSTAT -pub struct PropertyParameter(String); +pub struct PropertyParameter(pub String); +impl PropertyParameter { + pub fn as_str<'a>(&'a self) -> &'a str { + self.0.as_str() + } +} /// Name: time-range ///