aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dav/calencoder.rs33
-rw-r--r--src/dav/caltypes.rs20
2 files changed, 47 insertions, 6 deletions
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<C: CalContext> QuickWritable<C> for TimeOrText {
impl<C: CalContext> QuickWritable<C> for TextMatch {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, 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<C: CalContext> QuickWritable<C> for ParamFilter {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, 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<C: CalContext> QuickWritable<C> for ParamFilterMatch {
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, 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(),
+ }
+ }
+}
/// <!ELEMENT calendar-data (#PCDATA)>
@@ -1261,8 +1270,8 @@ pub struct TextMatch {
/// <!ATTLIST param-filter name CDATA #REQUIRED>
/// name value: a property parameter name (e.g., PARTSTAT)
pub struct ParamFilter {
- name: PropertyParameter,
- inner: Option<ParamFilterMatch>,
+ pub name: PropertyParameter,
+ pub additional_rules: Option<ParamFilterMatch>,
}
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
///