A little more preparation for new DAV Push spec

This commit is contained in:
Lennart
2025-05-02 22:22:58 +02:00
parent 6330021f05
commit 3170ca1d08
4 changed files with 91 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
use rustical_dav::header::Depth;
use rustical_xml::XmlSerialize;
use rustical_xml::{Unparsed, XmlDeserialize, XmlSerialize};
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
pub enum Transport {
@@ -22,23 +22,39 @@ impl Default for Transports {
}
}
#[derive(XmlSerialize, PartialEq, Clone)]
pub struct SupportedTriggers(#[xml(flatten, ty = "untagged")] pub Vec<SupportedTrigger>);
#[derive(XmlSerialize, XmlDeserialize, PartialEq, Clone)]
pub struct SupportedTriggers(#[xml(flatten, ty = "untagged")] pub Vec<Trigger>);
#[derive(XmlSerialize, PartialEq, Clone)]
pub enum SupportedTrigger {
#[derive(XmlSerialize, XmlDeserialize, PartialEq, Debug, Clone)]
pub enum Trigger {
#[xml(ns = "rustical_dav::namespace::NS_DAVPUSH")]
ContentUpdate(ContentUpdate),
#[xml(ns = "rustical_dav::namespace::NS_DAVPUSH")]
PropertyUpdate(PropertyUpdate),
}
#[derive(XmlSerialize, PartialEq, Clone)]
#[derive(XmlSerialize, XmlDeserialize, PartialEq, Clone, Debug)]
pub struct ContentUpdate(
#[xml(rename = b"depth", ns = "rustical_dav::namespace::NS_DAV")] pub Depth,
);
#[derive(XmlSerialize, PartialEq, Clone)]
#[derive(XmlSerialize, PartialEq, Clone, Debug)]
pub struct PropertyUpdate(
#[xml(rename = b"depth", ns = "rustical_dav::namespace::NS_DAV")] pub Depth,
);
impl XmlDeserialize for PropertyUpdate {
fn deserialize<R: std::io::BufRead>(
reader: &mut quick_xml::NsReader<R>,
start: &quick_xml::events::BytesStart,
empty: bool,
) -> Result<Self, rustical_xml::XmlError> {
#[derive(XmlDeserialize, PartialEq, Clone, Debug)]
struct FakePropertyUpdate(
#[xml(rename = b"depth", ns = "rustical_dav::namespace::NS_DAV")] pub Depth,
#[xml(rename = b"prop", ns = "rustical_dav::namespace::NS_DAV")] pub Unparsed,
);
let FakePropertyUpdate(depth, _) = FakePropertyUpdate::deserialize(reader, start, empty)?;
Ok(Self(depth))
}
}