mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 17:12:22 +00:00
Migrate propfind and report to rustical_xml
This commit is contained in:
@@ -4,7 +4,7 @@ mod resourcetype;
|
||||
pub mod tag_list;
|
||||
pub mod tag_name;
|
||||
|
||||
pub use propfind::{PropElement, PropfindType};
|
||||
pub use propfind::{PropElement, PropfindElement, PropfindType, Propname};
|
||||
|
||||
use derive_more::derive::From;
|
||||
pub use multistatus::MultistatusElement;
|
||||
|
||||
@@ -1,15 +1,26 @@
|
||||
use super::TagList;
|
||||
use serde::Deserialize;
|
||||
use rustical_xml::XmlDeserialize;
|
||||
use rustical_xml::XmlRootTag;
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct PropElement {
|
||||
#[serde(flatten)]
|
||||
pub prop: TagList,
|
||||
#[derive(Debug, Clone, XmlDeserialize, XmlRootTag, PartialEq)]
|
||||
#[xml(root = b"propfind", ns = b"DAV:")]
|
||||
pub struct PropfindElement {
|
||||
#[xml(ty = "untagged")]
|
||||
pub prop: PropfindType,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[derive(Debug, Clone, XmlDeserialize, PartialEq)]
|
||||
pub struct PropElement {
|
||||
#[xml(ty = "untagged", flatten)]
|
||||
pub prop: Vec<Propname>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, XmlDeserialize, PartialEq)]
|
||||
pub struct Propname {
|
||||
#[xml(ty = "tag_name")]
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, XmlDeserialize, PartialEq)]
|
||||
pub enum PropfindType {
|
||||
Propname,
|
||||
Allprop,
|
||||
|
||||
@@ -1,44 +1,10 @@
|
||||
use derive_more::derive::From;
|
||||
use serde::ser::SerializeMap;
|
||||
|
||||
use serde::{
|
||||
de::{MapAccess, Visitor},
|
||||
Deserialize, Serialize,
|
||||
};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, From)]
|
||||
pub struct TagList(Vec<String>);
|
||||
|
||||
struct TagListVisitor;
|
||||
|
||||
impl<'de> Visitor<'de> for TagListVisitor {
|
||||
type Value = TagList;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
formatter.write_str("TagList")
|
||||
}
|
||||
|
||||
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
A: MapAccess<'de>,
|
||||
{
|
||||
let mut tags = Vec::new();
|
||||
while let Some(key) = map.next_key::<String>()? {
|
||||
tags.push(key);
|
||||
}
|
||||
Ok(TagList(tags))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for TagList {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
deserializer.deserialize_map(TagListVisitor)
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for TagList {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user