Serialize another caldav filter
This commit is contained in:
parent
17142bd687
commit
99f8085e47
2 changed files with 94 additions and 33 deletions
|
@ -470,61 +470,124 @@ impl<C: CalContext> QuickWritable<C> for Expand {
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for LimitRecurrenceSet {
|
impl<C: CalContext> QuickWritable<C> for LimitRecurrenceSet {
|
||||||
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 empty = ctx.create_cal_element("limit-recurrence-set");
|
||||||
|
empty.push_attribute(("start", format!("{}", self.0.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
|
empty.push_attribute(("end", format!("{}", self.1.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
|
xml.write_event_async(Event::Empty(empty)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for LimitFreebusySet {
|
impl<C: CalContext> QuickWritable<C> for LimitFreebusySet {
|
||||||
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 empty = ctx.create_cal_element("limit-freebusy-set");
|
||||||
|
empty.push_attribute(("start", format!("{}", self.0.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
|
empty.push_attribute(("end", format!("{}", self.1.format(ICAL_DATETIME_FMT)).as_str()));
|
||||||
|
xml.write_event_async(Event::Empty(empty)).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CalendarSelector<C> {
|
impl<C: CalContext> QuickWritable<C> for CalendarSelector<C> {
|
||||||
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::AllProp => xml.write_event_async(Event::Empty(ctx.create_dav_element("allprop"))).await,
|
||||||
|
Self::PropName => xml.write_event_async(Event::Empty(ctx.create_dav_element("propname"))).await,
|
||||||
|
Self::Prop(prop) => prop.write(xml, ctx).await,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CompFilter {
|
impl<C: CalContext> QuickWritable<C> for CompFilter {
|
||||||
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("comp-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 CompFilterInner {
|
impl<C: CalContext> QuickWritable<C> for CompFilterRules {
|
||||||
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::Matches(cfm) => cfm.write(xml, ctx).await,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for CompFilterMatch {
|
impl<C: CalContext> QuickWritable<C> for CompFilterMatch {
|
||||||
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!();
|
if let Some(time_range) = &self.time_range {
|
||||||
|
time_range.write(xml, ctx.child()).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
for prop_item in self.prop_filter.iter() {
|
||||||
|
prop_item.write(xml, ctx.child()).await?;
|
||||||
|
}
|
||||||
|
for comp_item in self.comp_filter.iter() {
|
||||||
|
// Required: recursion in an async fn requires boxing
|
||||||
|
// rustc --explain E0733
|
||||||
|
Box::pin(comp_item.write(xml, ctx.child())).await?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for PropFilter {
|
impl<C: CalContext> QuickWritable<C> for PropFilter {
|
||||||
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("prop-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 PropFilterInner {
|
impl<C: CalContext> QuickWritable<C> for PropFilterRules {
|
||||||
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(prop_match) => prop_match.write(xml, ctx).await,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for PropFilterMatch {
|
impl<C: CalContext> QuickWritable<C> for PropFilterMatch {
|
||||||
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!();
|
if let Some(time_range) = &self.time_range {
|
||||||
|
time_range.write(xml, ctx.child()).await?;
|
||||||
|
}
|
||||||
|
if let Some(time_or_text) = &self.time_or_text {
|
||||||
|
time_or_text.write(xml, ctx.child()).await?;
|
||||||
|
}
|
||||||
|
for param_item in self.param_filter.iter() {
|
||||||
|
param_item.write(xml, ctx.child()).await?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalContext> QuickWritable<C> for TimeOrText {
|
impl<C: CalContext> QuickWritable<C> for TimeOrText {
|
||||||
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::Time(time) => time.write(xml, ctx).await,
|
||||||
|
Self::Text(txt) => txt.write(xml, ctx).await,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1028,7 +1028,7 @@ pub struct Expand(pub DateTime<Utc>, pub DateTime<Utc>);
|
||||||
/// end CDATA #REQUIRED>
|
/// end CDATA #REQUIRED>
|
||||||
/// start value: an iCalendar "date with UTC time"
|
/// start value: an iCalendar "date with UTC time"
|
||||||
/// end value: an iCalendar "date with UTC time"
|
/// end value: an iCalendar "date with UTC time"
|
||||||
pub struct LimitRecurrenceSet(DateTime<Utc>, DateTime<Utc>);
|
pub struct LimitRecurrenceSet(pub DateTime<Utc>, pub DateTime<Utc>);
|
||||||
|
|
||||||
/// Name: limit-freebusy-set
|
/// Name: limit-freebusy-set
|
||||||
///
|
///
|
||||||
|
@ -1058,7 +1058,7 @@ pub struct LimitRecurrenceSet(DateTime<Utc>, DateTime<Utc>);
|
||||||
/// end CDATA #REQUIRED>
|
/// end CDATA #REQUIRED>
|
||||||
/// start value: an iCalendar "date with UTC time"
|
/// start value: an iCalendar "date with UTC time"
|
||||||
/// end value: an iCalendar "date with UTC time"
|
/// end value: an iCalendar "date with UTC time"
|
||||||
pub struct LimitFreebusySet(DateTime<Utc>, DateTime<Utc>);
|
pub struct LimitFreebusySet(pub DateTime<Utc>, pub DateTime<Utc>);
|
||||||
|
|
||||||
/// Used by CalendarQuery & CalendarMultiget
|
/// Used by CalendarQuery & CalendarMultiget
|
||||||
pub enum CalendarSelector<T: Dav::Extension> {
|
pub enum CalendarSelector<T: Dav::Extension> {
|
||||||
|
@ -1116,21 +1116,20 @@ pub enum CalendarSelector<T: Dav::Extension> {
|
||||||
/// name value: a calendar object or calendar component
|
/// name value: a calendar object or calendar component
|
||||||
/// type (e.g., VEVENT)
|
/// type (e.g., VEVENT)
|
||||||
pub struct CompFilter {
|
pub struct CompFilter {
|
||||||
name: Component,
|
pub name: Component,
|
||||||
inner: CompFilterInner,
|
// Option 1 = None, Option 2, 3, 4 = Some
|
||||||
|
pub additional_rules: Option<CompFilterRules>,
|
||||||
}
|
}
|
||||||
pub enum CompFilterInner {
|
pub enum CompFilterRules {
|
||||||
// Option 1
|
|
||||||
Empty,
|
|
||||||
// Option 2
|
// Option 2
|
||||||
IsNotDefined,
|
IsNotDefined,
|
||||||
// Options 3 & 4
|
// Options 3 & 4
|
||||||
Matches(CompFilterMatch),
|
Matches(CompFilterMatch),
|
||||||
}
|
}
|
||||||
pub struct CompFilterMatch {
|
pub struct CompFilterMatch {
|
||||||
time_range: Option<TimeRange>,
|
pub time_range: Option<TimeRange>,
|
||||||
prop_filter: Vec<PropFilter>,
|
pub prop_filter: Vec<PropFilter>,
|
||||||
comp_filter: Vec<CompFilter>,
|
pub comp_filter: Vec<CompFilter>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Name: prop-filter
|
/// Name: prop-filter
|
||||||
|
@ -1178,21 +1177,20 @@ pub struct CompFilterMatch {
|
||||||
/// <!ATTLIST prop-filter name CDATA #REQUIRED>
|
/// <!ATTLIST prop-filter name CDATA #REQUIRED>
|
||||||
/// name value: a calendar property name (e.g., ATTENDEE)
|
/// name value: a calendar property name (e.g., ATTENDEE)
|
||||||
pub struct PropFilter {
|
pub struct PropFilter {
|
||||||
name: Component,
|
pub name: Component,
|
||||||
inner: PropFilterInner,
|
// None = Option 1, Some() = Option 2, 3 & 4
|
||||||
|
pub additional_rules: Option<PropFilterRules>,
|
||||||
}
|
}
|
||||||
pub enum PropFilterInner {
|
pub enum PropFilterRules {
|
||||||
// Option 1
|
|
||||||
Empty,
|
|
||||||
// Option 2
|
// Option 2
|
||||||
IsNotDefined,
|
IsNotDefined,
|
||||||
// Options 3 & 4
|
// Options 3 & 4
|
||||||
Match(PropFilterMatch),
|
Match(PropFilterMatch),
|
||||||
}
|
}
|
||||||
pub struct PropFilterMatch {
|
pub struct PropFilterMatch {
|
||||||
time_range: Option<TimeRange>,
|
pub time_range: Option<TimeRange>,
|
||||||
time_or_text: Option<TimeOrText>,
|
pub time_or_text: Option<TimeOrText>,
|
||||||
param_filter: Vec<ParamFilter>,
|
pub param_filter: Vec<ParamFilter>,
|
||||||
}
|
}
|
||||||
pub enum TimeOrText {
|
pub enum TimeOrText {
|
||||||
Time(TimeRange),
|
Time(TimeRange),
|
||||||
|
@ -1228,9 +1226,9 @@ pub enum TimeOrText {
|
||||||
/// <!ATTLIST text-match collation CDATA "i;ascii-casemap"
|
/// <!ATTLIST text-match collation CDATA "i;ascii-casemap"
|
||||||
/// negate-condition (yes | no) "no">
|
/// negate-condition (yes | no) "no">
|
||||||
pub struct TextMatch {
|
pub struct TextMatch {
|
||||||
collation: Option<Collation>,
|
pub collation: Option<Collation>,
|
||||||
negate_condition: bool,
|
pub negate_condition: Option<bool>,
|
||||||
text: String,
|
pub text: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Name: param-filter
|
/// Name: param-filter
|
||||||
|
|
Loading…
Reference in a new issue