async_reply_derive/
lib.rs

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