Some initial work on xml parsing

This commit is contained in:
Lennart
2024-11-24 15:09:34 +01:00
parent 7dfa0c9062
commit a9ef680c30
14 changed files with 1132 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
use rustical_xml::XmlRoot;
use xml_derive::XmlDeserialize;
#[test]
fn test_struct_untagged_enum() {
#[derive(Debug, XmlDeserialize, PartialEq)]
struct Propfind {
prop: Prop,
}
#[derive(Debug, XmlDeserialize, PartialEq)]
struct Prop {
#[xml(untagged)]
prop: PropEnum,
}
#[derive(Debug, XmlDeserialize, PartialEq)]
enum PropEnum {
A,
B,
}
impl XmlRoot for Propfind {
fn root_tag() -> &'static [u8] {
b"propfind"
}
}
let doc = Propfind::parse_str(
r#"
<propfind>
<prop>
<A/>
</prop>
</propfind>
"#,
)
.unwrap();
assert_eq!(
doc,
Propfind {
prop: Prop { prop: PropEnum::A }
}
);
}