rustical_caldav/calendar/
prop.rs1use derive_more::derive::{From, Into};
2use rustical_dav::xml::TextCollation;
3use rustical_ical::CalendarObjectType;
4use rustical_xml::{XmlDeserialize, XmlSerialize};
5use strum_macros::VariantArray;
6
7#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)]
8pub struct SupportedCalendarComponent {
9 #[xml(ty = "attr")]
10 pub name: CalendarObjectType,
11}
12
13#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq)]
14pub struct SupportedCalendarComponentSet {
15 #[xml(ns = "rustical_dav::namespace::NS_CALDAV", flatten)]
16 pub comp: Vec<SupportedCalendarComponent>,
17}
18
19impl From<Vec<CalendarObjectType>> for SupportedCalendarComponentSet {
20 fn from(value: Vec<CalendarObjectType>) -> Self {
21 Self {
22 comp: value
23 .into_iter()
24 .map(SupportedCalendarComponent::from)
25 .collect(),
26 }
27 }
28}
29
30impl From<SupportedCalendarComponentSet> for Vec<CalendarObjectType> {
31 fn from(value: SupportedCalendarComponentSet) -> Self {
32 value
33 .comp
34 .into_iter()
35 .map(CalendarObjectType::from)
36 .collect()
37 }
38}
39
40#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)]
41pub struct SupportedCollation(#[xml(ty = "text")] pub TextCollation);
42
43#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq)]
44pub struct SupportedCollationSet(
45 #[xml(
46 ns = "rustical_dav::namespace::NS_CALDAV",
47 flatten,
48 rename = "supported-collation"
49 )]
50 pub Vec<SupportedCollation>,
51);
52
53impl Default for SupportedCollationSet {
54 fn default() -> Self {
55 Self(vec![
56 SupportedCollation(TextCollation::AsciiCasemap),
57 SupportedCollation(TextCollation::UnicodeCasemap),
58 SupportedCollation(TextCollation::Octet),
59 ])
60 }
61}
62
63#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
64pub struct CalendarData {
65 #[xml(ty = "attr")]
66 content_type: String,
67 #[xml(ty = "attr")]
68 version: String,
69}
70
71impl Default for CalendarData {
72 fn default() -> Self {
73 Self {
74 content_type: "text/calendar".to_owned(),
75 version: "2.0".to_owned(),
76 }
77 }
78}
79
80#[derive(Debug, Clone, XmlSerialize, Default, PartialEq, Eq)]
81pub struct SupportedCalendarData {
82 #[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
83 calendar_data: CalendarData,
84}
85
86#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq, VariantArray)]
87pub enum ReportMethod {
88 #[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
89 CalendarQuery,
90 #[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
91 CalendarMultiget,
92 #[xml(ns = "rustical_dav::namespace::NS_DAV")]
93 SyncCollection,
94}