mongodb_ro_derive/
lib.rs

1mod collection;
2mod column;
3mod model;
4
5use proc_macro::TokenStream;
6use syn::{ parse_macro_input, DeriveInput};
7use quote::quote;
8use crate::collection::{CollectionAttr, CollectionMeta};
9use crate::model::impl_model;
10
11#[proc_macro_derive(Model, attributes(model))]
12pub fn derive(item: TokenStream) -> TokenStream {
13    let ast = parse_macro_input!(item as DeriveInput);
14    let attrs = CollectionAttr::from_attrs(&ast.attrs);
15    let collection = CollectionMeta::new(&ast, &attrs);
16
17    //panic!("{:#?}", collection);
18    let model = impl_model(&collection);
19
20    TokenStream::from(quote! {
21            #model
22        })
23}
24
25