Re-enable cal encoder tests
This commit is contained in:
parent
8fec92a086
commit
1aafd752ca
5 changed files with 107 additions and 19 deletions
33
src/dav/caldecoder.rs
Normal file
33
src/dav/caldecoder.rs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
use super::types as dav;
|
||||||
|
use super::caltypes::*;
|
||||||
|
use super::xml;
|
||||||
|
use super::error;
|
||||||
|
|
||||||
|
// ---- ROOT ELEMENTS ---
|
||||||
|
|
||||||
|
// ---- EXTENSIONS ---
|
||||||
|
impl xml::QRead<Violation> for Violation {
|
||||||
|
async fn qread(&self, xml: &mut xml::Reader<impl xml::IRead>) -> Result<Option<Self>, error::ParsingError> {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl xml::QRead<Property> for Property {
|
||||||
|
async fn qread(&self, xml: &mut xml::Reader<impl xml::IRead>) -> Result<Option<Self>, error::ParsingError> {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl xml::QRead<PropertyRequest> for PropertyRequest {
|
||||||
|
async fn qread(&self, xml: &mut xml::Reader<impl xml::IRead>) -> Result<Option<Self>, error::ParsingError> {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl xml::QRead<ResourceType> for ResourceType {
|
||||||
|
async fn qread(&self, xml: &mut xml::Reader<impl xml::IRead>) -> Result<Option<Self>, error::ParsingError> {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- INNER XML ----
|
|
@ -662,19 +662,25 @@ impl QWrite for TimeRange {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::dav::types as dav;
|
use crate::dav::types as dav;
|
||||||
|
use crate::dav::realization::Calendar;
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
use chrono::{Utc,TimeZone,DateTime};
|
use chrono::{Utc,TimeZone,DateTime};
|
||||||
|
|
||||||
async fn serialize<C: Context, Q: QuickWritable<C>>(ctx: C, elem: &Q) -> String {
|
async fn serialize(elem: &impl QWrite) -> String {
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
let mut tokio_buffer = tokio::io::BufWriter::new(&mut buffer);
|
let mut tokio_buffer = tokio::io::BufWriter::new(&mut buffer);
|
||||||
let mut writer = Writer::new_with_indent(&mut tokio_buffer, b' ', 4);
|
let q = quick_xml::writer::Writer::new_with_indent(&mut tokio_buffer, b' ', 4);
|
||||||
elem.write(&mut writer, ctx).await.expect("xml serialization");
|
let ns_to_apply = vec![
|
||||||
|
("xmlns:D".into(), "DAV:".into()),
|
||||||
|
("xmlns:C".into(), "urn:ietf:params:xml:ns:caldav".into()),
|
||||||
|
];
|
||||||
|
let mut writer = Writer { q, ns_to_apply };
|
||||||
|
|
||||||
|
elem.qwrite(&mut writer).await.expect("xml serialization");
|
||||||
tokio_buffer.flush().await.expect("tokio buffer flush");
|
tokio_buffer.flush().await.expect("tokio buffer flush");
|
||||||
let got = std::str::from_utf8(buffer.as_slice()).unwrap();
|
let got = std::str::from_utf8(buffer.as_slice()).unwrap();
|
||||||
|
|
||||||
|
@ -684,8 +690,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn basic_violation() {
|
async fn basic_violation() {
|
||||||
let got = serialize(
|
let got = serialize(
|
||||||
CalExtension { root: true },
|
&dav::Error::<Calendar>(vec![
|
||||||
&dav::Error(vec![
|
|
||||||
dav::Violation::Extension(Violation::ResourceMustBeNull),
|
dav::Violation::Extension(Violation::ResourceMustBeNull),
|
||||||
])
|
])
|
||||||
).await;
|
).await;
|
||||||
|
@ -700,8 +705,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn rfc_calendar_query1_req() {
|
async fn rfc_calendar_query1_req() {
|
||||||
let got = serialize(
|
let got = serialize(
|
||||||
CalExtension { root: true },
|
&CalendarQuery::<Calendar> {
|
||||||
&CalendarQuery {
|
|
||||||
selector: Some(CalendarSelector::Prop(dav::PropName(vec![
|
selector: Some(CalendarSelector::Prop(dav::PropName(vec![
|
||||||
dav::PropertyRequest::GetEtag,
|
dav::PropertyRequest::GetEtag,
|
||||||
dav::PropertyRequest::Extension(PropertyRequest::CalendarData(CalendarDataRequest {
|
dav::PropertyRequest::Extension(PropertyRequest::CalendarData(CalendarDataRequest {
|
||||||
|
@ -806,8 +810,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn rfc_calendar_query1_res() {
|
async fn rfc_calendar_query1_res() {
|
||||||
let got = serialize(
|
let got = serialize(
|
||||||
CalExtension { root: true },
|
&dav::Multistatus::<Calendar> {
|
||||||
&dav::Multistatus {
|
|
||||||
responses: vec![
|
responses: vec![
|
||||||
dav::Response {
|
dav::Response {
|
||||||
href: dav::Href("http://cal.example.com/bernard/work/abcd2.ics".into()),
|
href: dav::Href("http://cal.example.com/bernard/work/abcd2.ics".into()),
|
||||||
|
@ -877,4 +880,3 @@ mod tests {
|
||||||
assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n");
|
assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ use super::types as dav;
|
||||||
/// instruction in Section 12.13.2 of [RFC2518].
|
/// instruction in Section 12.13.2 of [RFC2518].
|
||||||
///
|
///
|
||||||
/// <!ELEMENT mkcalendar (DAV:set)>
|
/// <!ELEMENT mkcalendar (DAV:set)>
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct MkCalendar<E: dav::Extension>(pub dav::Set<E>);
|
pub struct MkCalendar<E: dav::Extension>(pub dav::Set<E>);
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ pub struct MkCalendar<E: dav::Extension>(pub dav::Set<E>);
|
||||||
/// Definition:
|
/// Definition:
|
||||||
///
|
///
|
||||||
/// <!ELEMENT mkcol-response (propstat+)>
|
/// <!ELEMENT mkcol-response (propstat+)>
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct MkCalendarResponse<E: dav::Extension>(pub Vec<dav::PropStat<E>>);
|
pub struct MkCalendarResponse<E: dav::Extension>(pub Vec<dav::PropStat<E>>);
|
||||||
|
|
||||||
// --- (REPORT PART) ---
|
// --- (REPORT PART) ---
|
||||||
|
@ -59,6 +61,7 @@ pub struct MkCalendarResponse<E: dav::Extension>(pub Vec<dav::PropStat<E>>);
|
||||||
/// <!ELEMENT calendar-query ((DAV:allprop |
|
/// <!ELEMENT calendar-query ((DAV:allprop |
|
||||||
/// DAV:propname |
|
/// DAV:propname |
|
||||||
/// DAV:prop)?, filter, timezone?)>
|
/// DAV:prop)?, filter, timezone?)>
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CalendarQuery<E: dav::Extension> {
|
pub struct CalendarQuery<E: dav::Extension> {
|
||||||
pub selector: Option<CalendarSelector<E>>,
|
pub selector: Option<CalendarSelector<E>>,
|
||||||
pub filter: Filter,
|
pub filter: Filter,
|
||||||
|
@ -79,6 +82,7 @@ pub struct CalendarQuery<E: dav::Extension> {
|
||||||
/// <!ELEMENT calendar-multiget ((DAV:allprop |
|
/// <!ELEMENT calendar-multiget ((DAV:allprop |
|
||||||
/// DAV:propname |
|
/// DAV:propname |
|
||||||
/// DAV:prop)?, DAV:href+)>
|
/// DAV:prop)?, DAV:href+)>
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CalendarMultiget<E: dav::Extension> {
|
pub struct CalendarMultiget<E: dav::Extension> {
|
||||||
pub selector: Option<CalendarSelector<E>>,
|
pub selector: Option<CalendarSelector<E>>,
|
||||||
pub href: Vec<dav::Href>,
|
pub href: Vec<dav::Href>,
|
||||||
|
@ -95,14 +99,17 @@ pub struct CalendarMultiget<E: dav::Extension> {
|
||||||
///
|
///
|
||||||
/// Definition:
|
/// Definition:
|
||||||
/// <!ELEMENT free-busy-query (time-range)>
|
/// <!ELEMENT free-busy-query (time-range)>
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct FreeBusyQuery(pub TimeRange);
|
pub struct FreeBusyQuery(pub TimeRange);
|
||||||
|
|
||||||
// ----- Hooks -----
|
// ----- Hooks -----
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum ResourceType {
|
pub enum ResourceType {
|
||||||
Calendar,
|
Calendar,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check the matching Property object for documentation
|
/// Check the matching Property object for documentation
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum PropertyRequest {
|
pub enum PropertyRequest {
|
||||||
CalendarDescription,
|
CalendarDescription,
|
||||||
CalendarTimezone,
|
CalendarTimezone,
|
||||||
|
@ -116,6 +123,8 @@ pub enum PropertyRequest {
|
||||||
SupportedCollationSet,
|
SupportedCollationSet,
|
||||||
CalendarData(CalendarDataRequest),
|
CalendarData(CalendarDataRequest),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Property {
|
pub enum Property {
|
||||||
/// Name: calendar-description
|
/// Name: calendar-description
|
||||||
///
|
///
|
||||||
|
@ -591,6 +600,7 @@ pub enum Property {
|
||||||
CalendarData(CalendarDataPayload),
|
CalendarData(CalendarDataPayload),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Violation {
|
pub enum Violation {
|
||||||
/// (DAV:resource-must-be-null): A resource MUST NOT exist at the
|
/// (DAV:resource-must-be-null): A resource MUST NOT exist at the
|
||||||
/// Request-URI;
|
/// Request-URI;
|
||||||
|
@ -761,6 +771,7 @@ pub enum Violation {
|
||||||
/// If the client chooses a collation not supported by the server, the
|
/// If the client chooses a collation not supported by the server, the
|
||||||
/// server MUST respond with a CALDAV:supported-collation precondition
|
/// server MUST respond with a CALDAV:supported-collation precondition
|
||||||
/// error response.
|
/// error response.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct SupportedCollation(pub Collation);
|
pub struct SupportedCollation(pub Collation);
|
||||||
|
|
||||||
/// <!ELEMENT calendar-data (#PCDATA)>
|
/// <!ELEMENT calendar-data (#PCDATA)>
|
||||||
|
@ -769,6 +780,7 @@ pub struct SupportedCollation(pub Collation);
|
||||||
/// when nested in the DAV:prop XML element in a calendaring
|
/// when nested in the DAV:prop XML element in a calendaring
|
||||||
/// REPORT response to specify the content of a returned
|
/// REPORT response to specify the content of a returned
|
||||||
/// calendar object resource.
|
/// calendar object resource.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CalendarDataPayload {
|
pub struct CalendarDataPayload {
|
||||||
pub mime: Option<CalendarDataSupport>,
|
pub mime: Option<CalendarDataSupport>,
|
||||||
pub payload: String,
|
pub payload: String,
|
||||||
|
@ -781,6 +793,7 @@ pub struct CalendarDataPayload {
|
||||||
/// when nested in the DAV:prop XML element in a calendaring
|
/// when nested in the DAV:prop XML element in a calendaring
|
||||||
/// REPORT request to specify which parts of calendar object
|
/// REPORT request to specify which parts of calendar object
|
||||||
/// resources should be returned in the response;
|
/// resources should be returned in the response;
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CalendarDataRequest {
|
pub struct CalendarDataRequest {
|
||||||
pub mime: Option<CalendarDataSupport>,
|
pub mime: Option<CalendarDataSupport>,
|
||||||
pub comp: Option<Comp>,
|
pub comp: Option<Comp>,
|
||||||
|
@ -795,6 +808,7 @@ pub struct CalendarDataRequest {
|
||||||
/// when nested in the CALDAV:supported-calendar-data property
|
/// when nested in the CALDAV:supported-calendar-data property
|
||||||
/// to specify a supported media type for calendar object
|
/// to specify a supported media type for calendar object
|
||||||
/// resources;
|
/// resources;
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CalendarDataEmpty(pub Option<CalendarDataSupport>);
|
pub struct CalendarDataEmpty(pub Option<CalendarDataSupport>);
|
||||||
|
|
||||||
/// <!ATTLIST calendar-data content-type CDATA "text/calendar"
|
/// <!ATTLIST calendar-data content-type CDATA "text/calendar"
|
||||||
|
@ -803,6 +817,7 @@ pub struct CalendarDataEmpty(pub Option<CalendarDataSupport>);
|
||||||
/// version value: a version string
|
/// version value: a version string
|
||||||
/// attributes can be used on all three variants of the
|
/// attributes can be used on all three variants of the
|
||||||
/// CALDAV:calendar-data XML element.
|
/// CALDAV:calendar-data XML element.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CalendarDataSupport {
|
pub struct CalendarDataSupport {
|
||||||
pub content_type: String,
|
pub content_type: String,
|
||||||
pub version: String,
|
pub version: String,
|
||||||
|
@ -828,10 +843,13 @@ pub struct CalendarDataSupport {
|
||||||
/// However, the CALDAV:prop and CALDAV:allprop elements are defined
|
/// However, the CALDAV:prop and CALDAV:allprop elements are defined
|
||||||
/// in the "urn:ietf:params:xml:ns:caldav" namespace instead of the
|
/// in the "urn:ietf:params:xml:ns:caldav" namespace instead of the
|
||||||
/// "DAV:" namespace.
|
/// "DAV:" namespace.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Comp {
|
pub struct Comp {
|
||||||
pub name: Component,
|
pub name: Component,
|
||||||
pub additional_rules: Option<CompInner>,
|
pub additional_rules: Option<CompInner>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CompInner {
|
pub struct CompInner {
|
||||||
pub prop_kind: PropKind,
|
pub prop_kind: PropKind,
|
||||||
pub comp_kind: CompKind,
|
pub comp_kind: CompKind,
|
||||||
|
@ -850,6 +868,7 @@ pub struct CompInner {
|
||||||
/// <C:comp name="VEVENT"/>
|
/// <C:comp name="VEVENT"/>
|
||||||
/// <C:comp name="VTODO"/>
|
/// <C:comp name="VTODO"/>
|
||||||
/// </C:supported-calendar-component-set>
|
/// </C:supported-calendar-component-set>
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CompSupport(pub Component);
|
pub struct CompSupport(pub Component);
|
||||||
|
|
||||||
/// Name: allcomp
|
/// Name: allcomp
|
||||||
|
@ -865,6 +884,7 @@ pub struct CompSupport(pub Component);
|
||||||
/// Definition:
|
/// Definition:
|
||||||
///
|
///
|
||||||
/// <!ELEMENT allcomp EMPTY>
|
/// <!ELEMENT allcomp EMPTY>
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum CompKind {
|
pub enum CompKind {
|
||||||
AllComp,
|
AllComp,
|
||||||
Comp(Vec<Comp>),
|
Comp(Vec<Comp>),
|
||||||
|
@ -888,6 +908,7 @@ pub enum CompKind {
|
||||||
/// allprop element defined in [RFC2518]. However, the CALDAV:allprop
|
/// allprop element defined in [RFC2518]. However, the CALDAV:allprop
|
||||||
/// element is defined in the "urn:ietf:params:xml:ns:caldav"
|
/// element is defined in the "urn:ietf:params:xml:ns:caldav"
|
||||||
/// namespace instead of the "DAV:" namespace.
|
/// namespace instead of the "DAV:" namespace.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum PropKind {
|
pub enum PropKind {
|
||||||
AllProp,
|
AllProp,
|
||||||
Prop(Vec<CalProp>),
|
Prop(Vec<CalProp>),
|
||||||
|
@ -917,11 +938,13 @@ pub enum PropKind {
|
||||||
/// element defined in [RFC2518]. However, the CALDAV:prop element is
|
/// element defined in [RFC2518]. However, the CALDAV:prop element is
|
||||||
/// defined in the "urn:ietf:params:xml:ns:caldav" namespace instead
|
/// defined in the "urn:ietf:params:xml:ns:caldav" namespace instead
|
||||||
/// of the "DAV:" namespace.
|
/// of the "DAV:" namespace.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CalProp {
|
pub struct CalProp {
|
||||||
pub name: ComponentProperty,
|
pub name: ComponentProperty,
|
||||||
pub novalue: Option<bool>,
|
pub novalue: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum RecurrenceModifier {
|
pub enum RecurrenceModifier {
|
||||||
Expand(Expand),
|
Expand(Expand),
|
||||||
LimitRecurrenceSet(LimitRecurrenceSet),
|
LimitRecurrenceSet(LimitRecurrenceSet),
|
||||||
|
@ -967,6 +990,7 @@ pub enum RecurrenceModifier {
|
||||||
/// 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"
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Expand(pub DateTime<Utc>, pub DateTime<Utc>);
|
pub struct Expand(pub DateTime<Utc>, pub DateTime<Utc>);
|
||||||
|
|
||||||
/// CALDAV:limit-recurrence-set XML Element
|
/// CALDAV:limit-recurrence-set XML Element
|
||||||
|
@ -1014,6 +1038,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"
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct LimitRecurrenceSet(pub DateTime<Utc>, pub DateTime<Utc>);
|
pub struct LimitRecurrenceSet(pub DateTime<Utc>, pub DateTime<Utc>);
|
||||||
|
|
||||||
/// Name: limit-freebusy-set
|
/// Name: limit-freebusy-set
|
||||||
|
@ -1044,9 +1069,11 @@ pub struct LimitRecurrenceSet(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"
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct LimitFreebusySet(pub DateTime<Utc>, pub DateTime<Utc>);
|
pub struct LimitFreebusySet(pub DateTime<Utc>, pub DateTime<Utc>);
|
||||||
|
|
||||||
/// Used by CalendarQuery & CalendarMultiget
|
/// Used by CalendarQuery & CalendarMultiget
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum CalendarSelector<E: dav::Extension> {
|
pub enum CalendarSelector<E: dav::Extension> {
|
||||||
AllProp,
|
AllProp,
|
||||||
PropName,
|
PropName,
|
||||||
|
@ -1101,17 +1128,20 @@ pub enum CalendarSelector<E: dav::Extension> {
|
||||||
/// <!ATTLIST comp-filter name CDATA #REQUIRED>
|
/// <!ATTLIST comp-filter name CDATA #REQUIRED>
|
||||||
/// name value: a calendar object or calendar component
|
/// name value: a calendar object or calendar component
|
||||||
/// type (e.g., VEVENT)
|
/// type (e.g., VEVENT)
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CompFilter {
|
pub struct CompFilter {
|
||||||
pub name: Component,
|
pub name: Component,
|
||||||
// Option 1 = None, Option 2, 3, 4 = Some
|
// Option 1 = None, Option 2, 3, 4 = Some
|
||||||
pub additional_rules: Option<CompFilterRules>,
|
pub additional_rules: Option<CompFilterRules>,
|
||||||
}
|
}
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum CompFilterRules {
|
pub enum CompFilterRules {
|
||||||
// Option 2
|
// Option 2
|
||||||
IsNotDefined,
|
IsNotDefined,
|
||||||
// Options 3 & 4
|
// Options 3 & 4
|
||||||
Matches(CompFilterMatch),
|
Matches(CompFilterMatch),
|
||||||
}
|
}
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct CompFilterMatch {
|
pub struct CompFilterMatch {
|
||||||
pub time_range: Option<TimeRange>,
|
pub time_range: Option<TimeRange>,
|
||||||
pub prop_filter: Vec<PropFilter>,
|
pub prop_filter: Vec<PropFilter>,
|
||||||
|
@ -1162,22 +1192,26 @@ 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)
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct PropFilter {
|
pub struct PropFilter {
|
||||||
pub name: Component,
|
pub name: Component,
|
||||||
// None = Option 1, Some() = Option 2, 3 & 4
|
// None = Option 1, Some() = Option 2, 3 & 4
|
||||||
pub additional_rules: Option<PropFilterRules>,
|
pub additional_rules: Option<PropFilterRules>,
|
||||||
}
|
}
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum PropFilterRules {
|
pub enum PropFilterRules {
|
||||||
// Option 2
|
// Option 2
|
||||||
IsNotDefined,
|
IsNotDefined,
|
||||||
// Options 3 & 4
|
// Options 3 & 4
|
||||||
Match(PropFilterMatch),
|
Match(PropFilterMatch),
|
||||||
}
|
}
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct PropFilterMatch {
|
pub struct PropFilterMatch {
|
||||||
pub time_range: Option<TimeRange>,
|
pub time_range: Option<TimeRange>,
|
||||||
pub time_or_text: Option<TimeOrText>,
|
pub time_or_text: Option<TimeOrText>,
|
||||||
pub param_filter: Vec<ParamFilter>,
|
pub param_filter: Vec<ParamFilter>,
|
||||||
}
|
}
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum TimeOrText {
|
pub enum TimeOrText {
|
||||||
Time(TimeRange),
|
Time(TimeRange),
|
||||||
Text(TextMatch),
|
Text(TextMatch),
|
||||||
|
@ -1211,6 +1245,7 @@ pub enum TimeOrText {
|
||||||
/// PCDATA value: string
|
/// PCDATA value: string
|
||||||
/// <!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">
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct TextMatch {
|
pub struct TextMatch {
|
||||||
pub collation: Option<Collation>,
|
pub collation: Option<Collation>,
|
||||||
pub negate_condition: Option<bool>,
|
pub negate_condition: Option<bool>,
|
||||||
|
@ -1246,10 +1281,12 @@ 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)
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct ParamFilter {
|
pub struct ParamFilter {
|
||||||
pub name: PropertyParameter,
|
pub name: PropertyParameter,
|
||||||
pub additional_rules: Option<ParamFilterMatch>,
|
pub additional_rules: Option<ParamFilterMatch>,
|
||||||
}
|
}
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum ParamFilterMatch {
|
pub enum ParamFilterMatch {
|
||||||
IsNotDefined,
|
IsNotDefined,
|
||||||
Match(TextMatch),
|
Match(TextMatch),
|
||||||
|
@ -1305,6 +1342,7 @@ pub enum ParamFilterMatch {
|
||||||
///
|
///
|
||||||
/// <!ELEMENT timezone (#PCDATA)>
|
/// <!ELEMENT timezone (#PCDATA)>
|
||||||
/// PCDATA value: an iCalendar object with exactly one VTIMEZONE
|
/// PCDATA value: an iCalendar object with exactly one VTIMEZONE
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct TimeZone(pub String);
|
pub struct TimeZone(pub String);
|
||||||
|
|
||||||
/// Name: filter
|
/// Name: filter
|
||||||
|
@ -1320,6 +1358,7 @@ pub struct TimeZone(pub String);
|
||||||
///
|
///
|
||||||
/// Definition:
|
/// Definition:
|
||||||
/// <!ELEMENT filter (comp-filter)>
|
/// <!ELEMENT filter (comp-filter)>
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Filter(pub CompFilter);
|
pub struct Filter(pub CompFilter);
|
||||||
|
|
||||||
/// Name: time-range
|
/// Name: time-range
|
||||||
|
@ -1331,6 +1370,7 @@ pub struct Filter(pub CompFilter);
|
||||||
/// end CDATA #IMPLIED>
|
/// end CDATA #IMPLIED>
|
||||||
/// 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"
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum TimeRange {
|
pub enum TimeRange {
|
||||||
OnlyStart(DateTime<Utc>),
|
OnlyStart(DateTime<Utc>),
|
||||||
OnlyEnd(DateTime<Utc>),
|
OnlyEnd(DateTime<Utc>),
|
||||||
|
@ -1340,6 +1380,7 @@ pub enum TimeRange {
|
||||||
// ----------------------- ENUM ATTRIBUTES ---------------------
|
// ----------------------- ENUM ATTRIBUTES ---------------------
|
||||||
|
|
||||||
/// Known components
|
/// Known components
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Component {
|
pub enum Component {
|
||||||
VCalendar,
|
VCalendar,
|
||||||
VJournal,
|
VJournal,
|
||||||
|
@ -1368,9 +1409,11 @@ impl Component {
|
||||||
/// name="VERSION", name="SUMMARY", etc.
|
/// name="VERSION", name="SUMMARY", etc.
|
||||||
/// Can be set on different objects: VCalendar, VEvent, etc.
|
/// Can be set on different objects: VCalendar, VEvent, etc.
|
||||||
/// Might be replaced by an enum later
|
/// Might be replaced by an enum later
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct ComponentProperty(pub String);
|
pub struct ComponentProperty(pub String);
|
||||||
|
|
||||||
/// like PARSTAT
|
/// like PARSTAT
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct PropertyParameter(pub String);
|
pub struct PropertyParameter(pub String);
|
||||||
impl PropertyParameter {
|
impl PropertyParameter {
|
||||||
pub fn as_str<'a>(&'a self) -> &'a str {
|
pub fn as_str<'a>(&'a self) -> &'a str {
|
||||||
|
@ -1378,7 +1421,7 @@ impl PropertyParameter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default,Debug,PartialEq)]
|
||||||
pub enum Collation {
|
pub enum Collation {
|
||||||
#[default]
|
#[default]
|
||||||
AsciiCaseMap,
|
AsciiCaseMap,
|
||||||
|
|
|
@ -1,14 +1,25 @@
|
||||||
|
// utils
|
||||||
mod error;
|
mod error;
|
||||||
mod xml;
|
mod xml;
|
||||||
|
|
||||||
|
// webdav
|
||||||
mod types;
|
mod types;
|
||||||
|
mod encoder;
|
||||||
|
mod decoder;
|
||||||
|
|
||||||
|
// calendar
|
||||||
mod caltypes;
|
mod caltypes;
|
||||||
|
mod calencoder;
|
||||||
|
mod caldecoder;
|
||||||
|
|
||||||
|
// wip
|
||||||
mod acltypes;
|
mod acltypes;
|
||||||
mod versioningtypes;
|
mod versioningtypes;
|
||||||
mod encoder;
|
|
||||||
mod calencoder;
|
// final type
|
||||||
mod decoder;
|
|
||||||
mod realization;
|
mod realization;
|
||||||
|
|
||||||
|
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
|
|
|
@ -28,14 +28,13 @@ impl dav::Extension for Core {
|
||||||
type ResourceType = Disabled;
|
type ResourceType = Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// WebDAV with the base Calendar implementation (RFC4791)
|
// WebDAV with the base Calendar implementation (RFC4791)
|
||||||
pub struct CalendarMin {}
|
pub struct Calendar {}
|
||||||
impl dav::Extension for CalendarMin
|
impl dav::Extension for Calendar
|
||||||
{
|
{
|
||||||
type Error = cal::Violation;
|
type Error = cal::Violation;
|
||||||
type Property = cal::Property;
|
type Property = cal::Property;
|
||||||
type PropertyRequest = cal::PropertyRequest;
|
type PropertyRequest = cal::PropertyRequest;
|
||||||
type ResourceType = cal::ResourceType;
|
type ResourceType = cal::ResourceType;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
Loading…
Reference in a new issue