json_api_derive 0.1.0

Code generation for json_api
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
extern crate proc_macro;
use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveInput};

mod context;
use context::ResourceContext;

#[proc_macro_derive(Resource, attributes(json_api))]
pub fn resource_macro_derive(input: TokenStream) -> TokenStream {
    impl_resource_macro(parse_macro_input!(input as DeriveInput))
}

fn impl_resource_macro(ast: DeriveInput) -> TokenStream {
    ResourceContext::from(&ast).to_token_stream().into()
}