mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 23:38:19 +00:00
xml: Add serialization
This commit is contained in:
@@ -16,6 +16,18 @@ pub fn derive_xml_deserialize(input: proc_macro::TokenStream) -> proc_macro::Tok
|
||||
.into()
|
||||
}
|
||||
|
||||
#[proc_macro_derive(XmlSerialize, attributes(xml))]
|
||||
pub fn derive_xml_serialize(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
|
||||
match &input.data {
|
||||
syn::Data::Enum(e) => Enum::parse(&input, e).impl_se(),
|
||||
syn::Data::Struct(s) => NamedStruct::parse(&input, s).impl_se(),
|
||||
syn::Data::Union(_) => panic!("Union not supported"),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
#[proc_macro_derive(XmlRoot, attributes(xml))]
|
||||
pub fn derive_xml_root(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
|
||||
Reference in New Issue
Block a user