Refactoring

This commit is contained in:
Lennart
2024-11-06 15:57:10 +01:00
parent ae4d5f0fc6
commit c21993ab15
17 changed files with 85 additions and 128 deletions

View File

@@ -1,8 +1,11 @@
pub mod multistatus;
mod propfind;
mod resourcetype;
pub mod tag_list;
pub mod tag_name;
pub use propfind::{PropElement, PropfindType};
use derive_more::derive::From;
pub use multistatus::MultistatusElement;
pub use tag_list::TagList;

View File

@@ -37,7 +37,7 @@ pub struct ResponseElement<PropstatType: Serialize> {
pub href: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
pub propstat: Vec<PropstatType>,
pub propstat: Vec<PropstatWrapper<PropstatType>>,
}
impl<PT: Serialize> Default for ResponseElement<PT> {
@@ -55,11 +55,11 @@ impl<PT: Serialize> Default for ResponseElement<PT> {
// Extended by sync-token as specified in RFC 6578
#[derive(Serialize)]
#[serde(rename = "multistatus", rename_all = "kebab-case")]
pub struct MultistatusElement<T1: Serialize, T2: Serialize> {
pub struct MultistatusElement<PropType: Serialize, MemberPropType: Serialize> {
#[serde(rename = "response")]
pub responses: Vec<ResponseElement<T1>>,
pub responses: Vec<ResponseElement<PropType>>,
#[serde(rename = "response")]
pub member_responses: Vec<ResponseElement<T2>>,
pub member_responses: Vec<ResponseElement<MemberPropType>>,
#[serde(rename = "@xmlns")]
pub ns_dav: &'static str,
#[serde(rename = "@xmlns:C")]

View File

@@ -0,0 +1,17 @@
use super::TagList;
use serde::Deserialize;
#[derive(Deserialize, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct PropElement {
#[serde(flatten)]
pub prop: TagList,
}
#[derive(Deserialize, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum PropfindType {
Propname,
Allprop,
Prop(PropElement),
}