mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
caldav: Fix SupportedCalendarComponentSet
This commit is contained in:
@@ -1,29 +1,22 @@
|
|||||||
use rustical_xml::XmlSerialize;
|
use rustical_xml::XmlSerialize;
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub struct SupportedCalendarComponent {
|
pub struct SupportedCalendarComponent {
|
||||||
#[serde(rename = "@name")]
|
|
||||||
#[xml(ty = "attr")]
|
#[xml(ty = "attr")]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub struct SupportedCalendarComponentSet {
|
pub struct SupportedCalendarComponentSet {
|
||||||
#[serde(rename = "C:comp")]
|
// #[serde(rename = "C:comp")]
|
||||||
#[xml(flatten)]
|
#[xml(flatten)]
|
||||||
pub comp: Vec<SupportedCalendarComponent>,
|
pub comp: Vec<SupportedCalendarComponent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub struct CalendarData {
|
pub struct CalendarData {
|
||||||
#[serde(rename = "@content-type")]
|
|
||||||
#[xml(ty = "attr")]
|
#[xml(ty = "attr")]
|
||||||
content_type: String,
|
content_type: String,
|
||||||
#[serde(rename = "@version")]
|
|
||||||
#[xml(ty = "attr")]
|
#[xml(ty = "attr")]
|
||||||
version: String,
|
version: String,
|
||||||
}
|
}
|
||||||
@@ -37,86 +30,68 @@ impl Default for CalendarData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, Default, PartialEq)]
|
#[derive(Debug, Clone, XmlSerialize, Default, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub struct SupportedCalendarData {
|
pub struct SupportedCalendarData {
|
||||||
#[serde(rename = "C:calendar-data", alias = "calendar-data")]
|
// #[serde(rename = "C:calendar-data", alias = "calendar-data")]
|
||||||
calendar_data: CalendarData,
|
calendar_data: CalendarData,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub enum ReportMethod {
|
pub enum ReportMethod {
|
||||||
CalendarQuery,
|
CalendarQuery,
|
||||||
CalendarMultiget,
|
CalendarMultiget,
|
||||||
SyncCollection,
|
SyncCollection,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub struct ReportWrapper {
|
pub struct ReportWrapper {
|
||||||
#[serde(rename = "$value")]
|
|
||||||
#[xml(ty = "untagged")]
|
|
||||||
report: ReportMethod,
|
report: ReportMethod,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, PartialEq)]
|
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub struct SupportedReportWrapper {
|
|
||||||
report: ReportWrapper,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ReportMethod> for SupportedReportWrapper {
|
|
||||||
fn from(value: ReportMethod) -> Self {
|
|
||||||
Self {
|
|
||||||
report: ReportWrapper { report: value },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RFC 3253 section-3.1.5
|
// RFC 3253 section-3.1.5
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub struct SupportedReportSet {
|
pub struct SupportedReportSet {
|
||||||
#[xml(flatten)]
|
#[xml(flatten)]
|
||||||
supported_report: Vec<SupportedReportWrapper>,
|
supported_report: Vec<ReportWrapper>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SupportedReportSet {
|
impl Default for SupportedReportSet {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
supported_report: vec![
|
supported_report: vec![
|
||||||
ReportMethod::CalendarQuery.into(),
|
ReportWrapper {
|
||||||
ReportMethod::CalendarMultiget.into(),
|
report: ReportMethod::CalendarQuery,
|
||||||
ReportMethod::SyncCollection.into(),
|
},
|
||||||
|
ReportWrapper {
|
||||||
|
report: ReportMethod::CalendarMultiget,
|
||||||
|
},
|
||||||
|
ReportWrapper {
|
||||||
|
report: ReportMethod::SyncCollection,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub enum Transport {
|
pub enum Transport {
|
||||||
#[serde(rename = "P:web-push")]
|
// #[serde(rename = "P:web-push")]
|
||||||
WebPush,
|
WebPush,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub struct TransportWrapper {
|
pub struct TransportWrapper {
|
||||||
#[serde(rename = "$value")]
|
|
||||||
#[xml(ty = "untagged")]
|
#[xml(ty = "untagged")]
|
||||||
transport: Transport,
|
transport: Transport,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
pub struct Transports {
|
pub struct Transports {
|
||||||
// NOTE: Here we implement an older version of the spec since the new property name is not reflected
|
// NOTE: Here we implement an older version of the spec since the new property name is not reflected
|
||||||
// in DAVx5 yet
|
// in DAVx5 yet
|
||||||
// https://github.com/bitfireAT/webdav-push/commit/461259a2f2174454b2b00033419b11fac52b79e3
|
// https://github.com/bitfireAT/webdav-push/commit/461259a2f2174454b2b00033419b11fac52b79e3
|
||||||
#[serde(rename = "P:transport")]
|
// #[serde(rename = "P:transport")]
|
||||||
#[xml(flatten)]
|
#[xml(flatten, rename = b"transport")]
|
||||||
transports: Vec<TransportWrapper>,
|
transports: Vec<TransportWrapper>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user