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
#![allow(clippy::cognitive_complexity)]
#![recursion_limit = "256"]
extern crate proc_macro;
use std::convert::TryFrom as _;
use proc_macro::TokenStream;
use quote::ToTokens;
use syn::parse_macro_input;
use self::api::{Api, RawApi};
mod api;
#[proc_macro]
pub fn ruma_api(input: TokenStream) -> TokenStream {
let raw_api = parse_macro_input!(input as RawApi);
match Api::try_from(raw_api) {
Ok(api) => api.into_token_stream().into(),
Err(err) => err.to_compile_error().into(),
}
}