xml: some refactoring

This commit is contained in:
Lennart
2024-12-22 15:18:43 +01:00
parent cd4137cda1
commit 241b356e44
5 changed files with 109 additions and 82 deletions

View File

@@ -2,14 +2,14 @@ use core::panic;
use syn::{parse_macro_input, DeriveInput};
mod de;
use de::{impl_de_enum, NamedStruct};
use de::{Enum, NamedStruct};
#[proc_macro_derive(XmlDeserialize, attributes(xml))]
pub fn derive_xml_deserialize(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(input as DeriveInput);
match &input.data {
syn::Data::Enum(e) => impl_de_enum(&input, e),
syn::Data::Enum(e) => Enum::parse(&input, e).impl_de(),
syn::Data::Struct(s) => NamedStruct::parse(&input, s).impl_de(),
syn::Data::Union(_) => panic!("Union not supported"),
}