rustical_dav/xml/
report_set.rs

1use rustical_xml::XmlSerialize;
2use strum::VariantArray;
3
4// RFC 3253 section-3.1.5
5#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
6pub struct SupportedReportSet<T: XmlSerialize + 'static> {
7    #[xml(flatten)]
8    #[xml(ns = "crate::namespace::NS_DAV")]
9    supported_report: Vec<ReportWrapper<T>>,
10}
11
12impl<T: XmlSerialize + Clone + 'static> SupportedReportSet<T> {
13    #[must_use]
14    pub fn new(methods: Vec<T>) -> Self {
15        Self {
16            supported_report: methods
17                .into_iter()
18                .map(|method| ReportWrapper { report: method })
19                .collect(),
20        }
21    }
22
23    pub fn all() -> Self
24    where
25        T: VariantArray,
26    {
27        Self::new(T::VARIANTS.to_vec())
28    }
29}
30
31#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
32pub struct ReportWrapper<T: XmlSerialize> {
33    #[xml(ns = "crate::namespace::NS_DAV")]
34    report: T,
35}