mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 19:32:29 +00:00
Group some DAV properties in extensions
This commit is contained in:
37
crates/dav/src/extensions/davpush.rs
Normal file
37
crates/dav/src/extensions/davpush.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use crate::push::Transports;
|
||||
use rustical_xml::{EnumUnitVariants, EnumVariants, XmlDeserialize, XmlSerialize};
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumUnitVariants, EnumVariants)]
|
||||
#[xml(unit_variants_ident = "DavPushExtensionPropName")]
|
||||
pub enum DavPushExtensionProp {
|
||||
// WebDav Push
|
||||
#[xml(skip_deserializing)]
|
||||
#[xml(ns = "crate::namespace::NS_DAVPUSH")]
|
||||
Transports(Transports),
|
||||
#[xml(ns = "crate::namespace::NS_DAVPUSH")]
|
||||
Topic(String),
|
||||
}
|
||||
|
||||
pub trait DavPushExtension {
|
||||
fn get_topic(&self) -> String;
|
||||
|
||||
fn get_prop(
|
||||
&self,
|
||||
prop: &DavPushExtensionPropName,
|
||||
) -> Result<DavPushExtensionProp, crate::Error> {
|
||||
Ok(match &prop {
|
||||
DavPushExtensionPropName::Transports => {
|
||||
DavPushExtensionProp::Transports(Default::default())
|
||||
}
|
||||
DavPushExtensionPropName::Topic => DavPushExtensionProp::Topic(self.get_topic()),
|
||||
})
|
||||
}
|
||||
|
||||
fn set_prop(&self, _prop: DavPushExtensionProp) -> Result<(), crate::Error> {
|
||||
Err(crate::Error::PropReadOnly)
|
||||
}
|
||||
|
||||
fn remove_prop(&self, _prop: &DavPushExtensionPropName) -> Result<(), crate::Error> {
|
||||
Err(crate::Error::PropReadOnly)
|
||||
}
|
||||
}
|
||||
5
crates/dav/src/extensions/mod.rs
Normal file
5
crates/dav/src/extensions/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
mod davpush;
|
||||
mod synctoken;
|
||||
|
||||
pub use davpush::*;
|
||||
pub use synctoken::*;
|
||||
39
crates/dav/src/extensions/synctoken.rs
Normal file
39
crates/dav/src/extensions/synctoken.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use rustical_xml::{EnumUnitVariants, EnumVariants, XmlDeserialize, XmlSerialize};
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumUnitVariants, EnumVariants)]
|
||||
#[xml(unit_variants_ident = "SyncTokenExtensionPropName")]
|
||||
pub enum SyncTokenExtensionProp {
|
||||
// Collection Synchronization (RFC 6578)
|
||||
#[xml(ns = "crate::namespace::NS_DAV")]
|
||||
SyncToken(String),
|
||||
|
||||
// CalendarServer
|
||||
#[xml(ns = "crate::namespace::NS_CALENDARSERVER")]
|
||||
Getctag(String),
|
||||
}
|
||||
|
||||
pub trait SyncTokenExtension {
|
||||
fn get_synctoken(&self) -> String;
|
||||
|
||||
fn get_prop(
|
||||
&self,
|
||||
prop: &SyncTokenExtensionPropName,
|
||||
) -> Result<SyncTokenExtensionProp, crate::Error> {
|
||||
Ok(match &prop {
|
||||
SyncTokenExtensionPropName::SyncToken => {
|
||||
SyncTokenExtensionProp::SyncToken(self.get_synctoken())
|
||||
}
|
||||
SyncTokenExtensionPropName::Getctag => {
|
||||
SyncTokenExtensionProp::Getctag(self.get_synctoken())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn set_prop(&self, _prop: SyncTokenExtensionProp) -> Result<(), crate::Error> {
|
||||
Err(crate::Error::PropReadOnly)
|
||||
}
|
||||
|
||||
fn remove_prop(&self, _prop: &SyncTokenExtensionPropName) -> Result<(), crate::Error> {
|
||||
Err(crate::Error::PropReadOnly)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod depth_header;
|
||||
pub mod error;
|
||||
pub mod extensions;
|
||||
pub mod namespace;
|
||||
pub mod privileges;
|
||||
pub mod push;
|
||||
|
||||
Reference in New Issue
Block a user