codde_protocol_derive/
lib.rs

1use proc_macro::TokenStream;
2use quote::quote;
3use syn::{parse_macro_input, ItemStruct};
4
5#[proc_macro_derive(Widget)]
6pub fn widget_derive(input: TokenStream) -> TokenStream {
7    let input = parse_macro_input!(input as ItemStruct);
8
9    let name = &input.ident;
10
11    let output = quote! {
12        #[typetag::serde]
13        impl Widget for #name {
14            /* fn try_match(&self, s: &str) -> bool {
15                s == self.
16            }
17            fn as_any(&self) -> &dyn Any {
18                self
19            } */
20
21            /* fn get_identity(&self, id: u8) -> &str{
22                &format!("{}_{}", stringify!(#name), id)
23            } */
24
25            /* fn name(&self) -> &str {
26                stringify!(#name)
27            } */
28        }
29    };
30
31    // Return output TokenStream so your custom derive behavior will be attached.
32    // TokenStream::from(output)
33    output.into()
34}
35
36#[proc_macro_derive(ResultWidget)]
37pub fn result_widget_derive(input: TokenStream) -> TokenStream {
38    let input = parse_macro_input!(input as ItemStruct);
39
40    let name = &input.ident;
41
42    let output = quote! {
43        #[typetag::serde]
44        impl ResultWidget for #name {
45        }
46    };
47
48    // Return output TokenStream so your custom derive behavior will be attached.
49    // TokenStream::from(output)
50    output.into()
51}