aboutsummaryrefslogblamecommitdiffstats
path: root/zotapi-derive/src/lib.rs
blob: ff44c9c46a526caf6dd88142b54558edc1bb74ee (plain) (tree)



















                                                                              
use proc_macro::{self, TokenStream};
use quote::*;
use syn::DeriveInput;

#[proc_macro_derive(ZotAPI)]
pub fn zotapi_derive(input: TokenStream) -> TokenStream {
    let ast = syn::parse(input).unwrap();
    impl_zotapi_derive(&ast)
}

fn impl_zotapi_derive(ast: &DeriveInput) -> TokenStream {
    let name = &ast.ident;    // The identifier of the struct we're called for
    let out_name = format_ident!("{}Request", name);

    let gen = quote! {
        impl ZotAPI<#out_name> for #name {
        }
    };
    gen.into()
}