xml: Rename XmlRoot to XmlRootTag

This commit is contained in:
Lennart
2024-12-23 12:36:46 +01:00
parent b52a9f4fbe
commit 6721e876fa
7 changed files with 25 additions and 25 deletions

View File

@@ -47,7 +47,7 @@ pub struct NamedStruct {
}
impl NamedStruct {
pub fn impl_xml_root(&self) -> proc_macro2::TokenStream {
pub fn impl_xml_root_tag(&self) -> proc_macro2::TokenStream {
let (impl_generics, type_generics, where_clause) = self.generics.split_for_impl();
let ident = &self.ident;
let root = self.attrs.root.as_ref().expect("No root attribute found");
@@ -56,7 +56,7 @@ impl NamedStruct {
None => quote! { None },
};
quote! {
impl #impl_generics ::rustical_xml::XmlRoot for #ident #type_generics #where_clause {
impl #impl_generics ::rustical_xml::XmlRootTag for #ident #type_generics #where_clause {
fn root_tag() -> &'static [u8] { #root }
fn root_ns() -> Option<&'static [u8]> { #ns }
}

View File

@@ -28,12 +28,12 @@ pub fn derive_xml_serialize(input: proc_macro::TokenStream) -> proc_macro::Token
.into()
}
#[proc_macro_derive(XmlRoot, attributes(xml))]
pub fn derive_xml_root(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
#[proc_macro_derive(XmlRootTag, attributes(xml))]
pub fn derive_xml_root_tag(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(input as DeriveInput);
match &input.data {
syn::Data::Struct(s) => NamedStruct::parse(&input, s).impl_xml_root(),
syn::Data::Struct(s) => NamedStruct::parse(&input, s).impl_xml_root_tag(),
syn::Data::Enum(_) => panic!("Enum not supported as root"),
syn::Data::Union(_) => panic!("Union not supported as root"),
}