1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#![recursion_limit = "128"] //! Derive macros for `async-reply` message. //! //! ## Usage //! //! ```rust //! use async_reply::Message; //! //! #[derive(Message)] //! #[rtype(response = "Pong")] //! struct Ping; //! //! struct Pong; //! //! fn main() {} //! ``` //! //! This code expands into following code: //! //! ```rust //! use async_reply::Message; //! //! struct Ping; //! //! struct Pong; //! //! impl Message for Ping { //! type Response = Pong; //! } //! //! fn main() {} //! ``` extern crate proc_macro; use proc_macro::TokenStream; use syn::DeriveInput; mod message; #[proc_macro_derive(Message, attributes(rtype))] pub fn message_derive_rtype(input: TokenStream) -> TokenStream { let ast: DeriveInput = syn::parse(input).unwrap(); message::expand(&ast).into() }