1use std::borrow::Cow;
2
3#[derive(crate::Element)]
4#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
5#[xml_data("data", crate(crate))]
6pub struct Data {
7 #[xml_data(attr_string)]
8 pub key: Cow<'static, str>,
9 #[xml_data(attr)]
10 pub other: u32,
11 pub foo1: Option<Foo>,
12 pub inner: DataInner,
13}
14
15#[derive(crate::Inner)]
16#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
17#[xml_data(crate(crate))]
18pub struct DataInner {
19 pub foo2: Option<Foo>,
20 pub content: String,
21}
22
23impl Data {
24 pub const TEST_PARSE_DOCUMENT_1: &'static str = r#"<?xml version="1.1" encoding="utf-8"?>
25<data key="abc" other="42"><foo>
26 <unknown/>
27 </foo></data>"#;
28
29 pub const TEST_SERIALIZE_DOCUMENT_1: &'static str = r#"<?xml version="1.1" encoding="utf-8"?><data key="abc" other="42"><foo/></data>"#;
30
31 pub const TEST_RESULT_1: Self = Self {
32 key: Cow::Borrowed("abc"),
33 other: 42,
34 foo1: Some(Foo),
35 inner: DataInner {
36 foo2: None,
37 content: String::new(),
38 },
39 };
40}
41
42#[derive(crate::Element)]
43#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
44#[xml_data("foo", crate(crate), ignore_unknown)]
45pub struct Foo;