Files
rustical/crates/caldav/src/calendar/prop.rs
2024-10-31 21:18:41 +01:00

97 lines
2.4 KiB
Rust

use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct SupportedCalendarComponent {
#[serde(rename = "@name")]
pub name: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct SupportedCalendarComponentSet {
#[serde(rename = "C:comp")]
pub comp: Vec<SupportedCalendarComponent>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct CalendarData {
#[serde(rename = "@content-type")]
content_type: String,
#[serde(rename = "@version")]
version: String,
}
impl Default for CalendarData {
fn default() -> Self {
Self {
content_type: "text/calendar".to_owned(),
version: "2.0".to_owned(),
}
}
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
#[serde(rename_all = "kebab-case")]
pub struct SupportedCalendarData {
#[serde(rename = "C:calendar-data", alias = "calendar-data")]
calendar_data: CalendarData,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
#[serde(rename_all = "kebab-case")]
pub struct Resourcetype {
#[serde(rename = "C:calendar", alias = "calendar")]
calendar: (),
collection: (),
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum ReportMethod {
CalendarQuery,
CalendarMultiget,
SyncCollection,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct ReportWrapper {
#[serde(rename = "$value")]
report: ReportMethod,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[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
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct SupportedReportSet {
supported_report: Vec<SupportedReportWrapper>,
}
impl Default for SupportedReportSet {
fn default() -> Self {
Self {
supported_report: vec![
ReportMethod::CalendarQuery.into(),
ReportMethod::CalendarMultiget.into(),
ReportMethod::SyncCollection.into(),
],
}
}
}