xml: Implement XmlDocument for tagged enums and fix small bug

This commit is contained in:
Lennart
2024-12-23 13:02:59 +01:00
parent 6721e876fa
commit 98ed1a3fc5
5 changed files with 65 additions and 1 deletions

View File

@@ -39,3 +39,15 @@ pub fn derive_xml_root_tag(input: proc_macro::TokenStream) -> proc_macro::TokenS
}
.into()
}
#[proc_macro_derive(XmlDocument, attributes(xml))]
pub fn derive_xml_document(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(input as DeriveInput);
match &input.data {
syn::Data::Struct(_) => panic!("Struct not supported, use XmlRootTag instead"),
syn::Data::Enum(e) => Enum::parse(&input, e).impl_xml_document(),
syn::Data::Union(_) => panic!("Union not supported as root"),
}
.into()
}