arpy-macros 0.2.0

Macros for the Arpy RPC library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use heck::ToKebabCase;
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput};

#[proc_macro_derive(MsgId)]
pub fn derive_msg_id(item: TokenStream) -> TokenStream {
    let item: DeriveInput = parse_macro_input!(item);
    let ident = item.ident;
    let id = ident.to_string().to_kebab_case();

    quote!(
        impl ::arpy::protocol::MsgId for #ident {
            const ID: &'static str = #id;
        }
    )
    .into()
}