hifa_xml_schema_derive/
lib.rs

1extern crate proc_macro;
2#[macro_use]
3extern crate quote;
4#[macro_use]
5extern crate hifa_yaserde_derive;
6
7use crate::attribute::XmlSchemaAttributes;
8use darling::FromDeriveInput;
9use syn::DeriveInput;
10
11mod attribute;
12mod expander;
13mod xsd;
14
15#[proc_macro_derive(XmlSchema, attributes(xml_schema))]
16pub fn hifa_xml_schema_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
17  let input: DeriveInput =
18    syn::parse2(proc_macro2::TokenStream::from(input)).expect("Failed to parse input");
19
20  let attributes =
21    XmlSchemaAttributes::from_derive_input(&input).expect("Failed to parse attributes");
22
23  match expander::expand_derive(&attributes) {
24    Ok(expanded) => expanded.into(),
25    Err(msg) => panic!("{}", msg),
26  }
27}