Some preparation to parse CalDAV REPORT requests with calendar-data

This commit is contained in:
Lennart
2025-04-27 15:09:28 +02:00
parent 19708b7951
commit 3b58d73b58
6 changed files with 128 additions and 44 deletions

View File

@@ -9,17 +9,17 @@ pub struct PropfindElement {
}
#[derive(Debug, Clone, XmlDeserialize, PartialEq)]
pub struct PropElement(#[xml(ty = "untagged", flatten)] pub Vec<Propname>);
pub struct PropElement<PN: XmlDeserialize = Propname>(#[xml(ty = "untagged", flatten)] pub Vec<PN>);
#[derive(Debug, Clone, XmlDeserialize, PartialEq)]
pub struct Propname(#[xml(ty = "tag_name")] pub String);
#[derive(Debug, Clone, XmlDeserialize, PartialEq)]
pub enum PropfindType {
pub enum PropfindType<PN: XmlDeserialize = Propname> {
#[xml(ns = "crate::namespace::NS_DAV")]
Propname,
#[xml(ns = "crate::namespace::NS_DAV")]
Allprop,
#[xml(ns = "crate::namespace::NS_DAV")]
Prop(PropElement),
Prop(PropElement<PN>),
}

View File

@@ -1,6 +1,6 @@
use rustical_xml::{ValueDeserialize, ValueSerialize, XmlDeserialize};
use super::PropfindType;
use super::{PropfindType, Propname};
#[derive(Clone, Debug, PartialEq)]
pub enum SyncLevel {
@@ -16,7 +16,7 @@ impl ValueDeserialize for SyncLevel {
_ => {
return Err(rustical_xml::XmlError::InvalidValue(
rustical_xml::ParseValueError::Other("Invalid sync-level".to_owned()),
))
));
}
})
}
@@ -37,13 +37,13 @@ impl ValueSerialize for SyncLevel {
// <!-- DAV:limit defined in RFC 5323, Section 5.17 -->
// <!-- DAV:prop defined in RFC 4918, Section 14.18 -->
#[xml(ns = "crate::namespace::NS_DAV")]
pub struct SyncCollectionRequest {
pub struct SyncCollectionRequest<PN: XmlDeserialize = Propname> {
#[xml(ns = "crate::namespace::NS_DAV")]
pub sync_token: String,
#[xml(ns = "crate::namespace::NS_DAV")]
pub sync_level: SyncLevel,
#[xml(ns = "crate::namespace::NS_DAV", ty = "untagged")]
pub prop: PropfindType,
pub prop: PropfindType<PN>,
#[xml(ns = "crate::namespace::NS_DAV")]
pub limit: Option<u64>,
}