xml_schema_derive/
lib.rs

1extern crate proc_macro;
2#[macro_use]
3extern crate quote;
4#[macro_use]
5extern crate 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 xml_schema_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
17  let input: DeriveInput = syn::parse2(proc_macro2::TokenStream::from(input)).unwrap();
18
19  let attributes = XmlSchemaAttributes::from_derive_input(&input).unwrap();
20
21  match expander::expand_derive(&attributes) {
22    Ok(expanded) => expanded.into(),
23    Err(msg) => panic!("{}", msg),
24  }
25}