mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 10:32:19 +00:00
xml: Rename XmlRoot to XmlRootTag
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user