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)]
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    pub fn new(methods: Vec<T>) -> Self {
14        Self {
15            supported_report: methods
16                .into_iter()
17                .map(|method| ReportWrapper { report: method })
18                .collect(),
19        }
20    }
21
22    pub fn all() -> Self
23    where
24        T: VariantArray,
25    {
26        Self::new(T::VARIANTS.to_vec())
27    }
28}
29
30#[derive(Debug, Clone, XmlSerialize, PartialEq)]
31pub struct ReportWrapper<T: XmlSerialize> {
32    #[xml(ns = "crate::namespace::NS_DAV")]
33    report: T,
34}