Param-filter encoding
This commit is contained in:
parent
99f8085e47
commit
433e1f97f6
2 changed files with 47 additions and 6 deletions
|
@ -593,19 +593,46 @@ impl<C: CalContext> QuickWritable<C> for TimeOrText {
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for TextMatch {
|
impl<C: CalContext> QuickWritable<C> for TextMatch {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
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 {
|
impl<C: CalContext> QuickWritable<C> for ParamFilter {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
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 {
|
impl<C: CalContext> QuickWritable<C> for ParamFilterMatch {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
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,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -778,6 +778,15 @@ pub enum Collation {
|
||||||
Octet,
|
Octet,
|
||||||
Unknown(String),
|
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)>
|
/// <!ELEMENT calendar-data (#PCDATA)>
|
||||||
|
@ -1261,8 +1270,8 @@ pub struct TextMatch {
|
||||||
/// <!ATTLIST param-filter name CDATA #REQUIRED>
|
/// <!ATTLIST param-filter name CDATA #REQUIRED>
|
||||||
/// name value: a property parameter name (e.g., PARTSTAT)
|
/// name value: a property parameter name (e.g., PARTSTAT)
|
||||||
pub struct ParamFilter {
|
pub struct ParamFilter {
|
||||||
name: PropertyParameter,
|
pub name: PropertyParameter,
|
||||||
inner: Option<ParamFilterMatch>,
|
pub additional_rules: Option<ParamFilterMatch>,
|
||||||
}
|
}
|
||||||
pub enum ParamFilterMatch {
|
pub enum ParamFilterMatch {
|
||||||
IsNotDefined,
|
IsNotDefined,
|
||||||
|
@ -1366,7 +1375,12 @@ impl Component {
|
||||||
pub struct ComponentProperty(pub String);
|
pub struct ComponentProperty(pub String);
|
||||||
|
|
||||||
/// like PARSTAT
|
/// 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
|
/// Name: time-range
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue