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::Span;
use syn::{DeriveInput, LitStr};
use crate::common::meta::{MetaInfo, MetaName};

pub struct XmlEncoding;

impl XmlEncoding {
    pub fn parse(input: &DeriveInput) -> LitStr {
        let default = "UTF-8".to_string();
        let result = if let Some(declaration) = MetaInfo::from_name(&input.attrs, MetaName::Declaration) {
            declaration.get_or("encoding", default)
        } else {
            default
        };
        LitStr::new(&result, Span::call_site())
    }
}