xavier-derive 0.1.7

Derive module of Xavier. Xavier is a lightweight and versatile XML parsing library designed to streamline the process of handling XML data with ease and efficiency.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use proc_macro2::TokenStream;
use quote::quote;
use syn::DeriveInput;
use crate::common::meta::{MetaInfo, MetaName};
use crate::common::naming::names::XmlNames;

pub(crate) struct XmlSimpleTag;

impl XmlSimpleTag {
    pub fn parse(input: &DeriveInput) -> TokenStream {
        let meta_info = MetaInfo::from_name(&input.attrs, MetaName::XML);
        let tag = XmlNames::root(&input, meta_info.as_ref());
        quote! {
            let xml = format!("<{}>{}</{}>", #tag, &self.0.to_xml(None, false), #tag).to_string();
        }
    }
}