rustical_dav_push/
prop.rs

1use rustical_dav::header::Depth;
2use rustical_xml::{Unparsed, XmlDeserialize, XmlSerialize};
3
4#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
5pub enum Transport {
6    #[xml(ns = "rustical_dav::namespace::NS_DAVPUSH")]
7    WebPush,
8}
9
10#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
11pub struct Transports {
12    #[xml(flatten, ty = "untagged")]
13    #[xml(ns = "crate::namespace::NS_DAVPUSH")]
14    transports: Vec<Transport>,
15}
16
17impl Default for Transports {
18    fn default() -> Self {
19        Self {
20            transports: vec![Transport::WebPush],
21        }
22    }
23}
24
25#[derive(XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone, Debug)]
26pub struct SupportedTriggers(#[xml(flatten, ty = "untagged")] pub Vec<Trigger>);
27
28#[derive(XmlSerialize, XmlDeserialize, PartialEq, Eq, Debug, Clone)]
29pub enum Trigger {
30    #[xml(ns = "rustical_dav::namespace::NS_DAVPUSH")]
31    ContentUpdate(ContentUpdate),
32    #[xml(ns = "rustical_dav::namespace::NS_DAVPUSH")]
33    PropertyUpdate(PropertyUpdate),
34}
35
36#[derive(XmlSerialize, XmlDeserialize, PartialEq, Eq, Clone, Debug)]
37pub struct ContentUpdate(
38    #[xml(rename = "depth", ns = "rustical_dav::namespace::NS_DAV")] pub Depth,
39);
40
41#[derive(XmlSerialize, PartialEq, Eq, Clone, Debug)]
42pub struct PropertyUpdate(
43    #[xml(rename = "depth", ns = "rustical_dav::namespace::NS_DAV")] pub Depth,
44);
45
46impl XmlDeserialize for PropertyUpdate {
47    fn deserialize<R: std::io::BufRead>(
48        reader: &mut quick_xml::NsReader<R>,
49        start: &quick_xml::events::BytesStart,
50        empty: bool,
51    ) -> Result<Self, rustical_xml::XmlError> {
52        #[derive(XmlDeserialize, PartialEq, Clone, Debug)]
53        struct FakePropertyUpdate(
54            #[xml(rename = "depth", ns = "rustical_dav::namespace::NS_DAV")] pub Depth,
55            #[xml(rename = "prop", ns = "rustical_dav::namespace::NS_DAV")] pub Unparsed,
56        );
57        let FakePropertyUpdate(depth, _) = FakePropertyUpdate::deserialize(reader, start, empty)?;
58        Ok(Self(depth))
59    }
60}