mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 17:12:22 +00:00
Add namespaces to propnames
This commit is contained in:
@@ -5,7 +5,7 @@ pub struct Resourcetype(#[xml(flatten, ty = "untagged")] pub &'static [Resourcet
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, XmlSerialize)]
|
||||
pub struct ResourcetypeInner(
|
||||
#[xml(ty = "namespace")] pub quick_xml::name::Namespace<'static>,
|
||||
#[xml(ty = "namespace")] pub Option<quick_xml::name::Namespace<'static>>,
|
||||
#[xml(ty = "tag_name")] pub &'static str,
|
||||
);
|
||||
|
||||
@@ -27,8 +27,8 @@ mod tests {
|
||||
let mut writer = quick_xml::Writer::new(&mut buf);
|
||||
Document {
|
||||
resourcetype: Resourcetype(&[
|
||||
ResourcetypeInner(crate::namespace::NS_DAV, "displayname"),
|
||||
ResourcetypeInner(crate::namespace::NS_CALENDARSERVER, "calendar-color"),
|
||||
ResourcetypeInner(Some(crate::namespace::NS_DAV), "displayname"),
|
||||
ResourcetypeInner(Some(crate::namespace::NS_CALENDARSERVER), "calendar-color"),
|
||||
]),
|
||||
}
|
||||
.serialize_root(&mut writer)
|
||||
|
||||
@@ -4,7 +4,7 @@ use rustical_xml::XmlSerialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, From)]
|
||||
pub struct TagList(Vec<String>);
|
||||
pub struct TagList(Vec<(Option<Namespace<'static>>, String)>);
|
||||
|
||||
impl XmlSerialize for TagList {
|
||||
fn serialize<W: std::io::Write>(
|
||||
@@ -18,9 +18,18 @@ impl XmlSerialize for TagList {
|
||||
struct Inner(#[xml(ty = "untagged", flatten)] Vec<Tag>);
|
||||
|
||||
#[derive(Debug, XmlSerialize, PartialEq)]
|
||||
struct Tag(#[xml(ty = "tag_name")] String);
|
||||
Inner(self.0.iter().map(|t| Tag(t.to_owned())).collect())
|
||||
.serialize(ns, tag, namespaces, writer)
|
||||
struct Tag(
|
||||
#[xml(ty = "namespace")] Option<Namespace<'static>>,
|
||||
#[xml(ty = "tag_name")] String,
|
||||
);
|
||||
|
||||
Inner(
|
||||
self.0
|
||||
.iter()
|
||||
.map(|(ns, tag)| Tag(ns.to_owned(), tag.to_owned()))
|
||||
.collect(),
|
||||
)
|
||||
.serialize(ns, tag, namespaces, writer)
|
||||
}
|
||||
|
||||
#[allow(refining_impl_trait)]
|
||||
|
||||
Reference in New Issue
Block a user