xml: Add serialization

This commit is contained in:
Lennart
2024-12-23 10:46:33 +01:00
parent d9f7d1da2f
commit b5e0f68239
9 changed files with 141 additions and 33 deletions

View File

@@ -1,5 +1,4 @@
use rustical_xml::{de::XmlRootParseStr, Unit, XmlDeserialize, XmlRoot};
use std::io::BufRead;
#[test]
fn test_struct_tagged_enum() {
@@ -15,11 +14,17 @@ fn test_struct_tagged_enum() {
prop: Vec<PropEnum>,
}
#[derive(Debug, XmlDeserialize, PartialEq)]
struct Displayname {
#[xml(ty = "text")]
name: String,
}
#[derive(Debug, XmlDeserialize, PartialEq)]
enum PropEnum {
A,
B,
Displayname(String),
Displayname(Displayname),
}
let doc = Propfind::parse_str(
@@ -41,7 +46,9 @@ fn test_struct_tagged_enum() {
prop: vec![
PropEnum::B,
PropEnum::A,
PropEnum::Displayname("Hello!".to_owned())
PropEnum::Displayname(Displayname {
name: "Hello!".to_owned()
})
]
}
}