Skip to main content

beckon/
lib.rs

1#![doc = include_str!("../README.md")]
2
3extern crate proc_macro;
4
5use crate::expanders::ApiClientExpander;
6use crate::input::ApiClientInput;
7use syn::parse_macro_input;
8
9mod error;
10mod expanders;
11mod input;
12
13fn expand_macro(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
14    let input = parse_macro_input!(input as ApiClientInput);
15    match ApiClientExpander::new(input).expand() {
16        Ok(tokens) => tokens.into(),
17        Err(err) => err.into_compile_error().into(),
18    }
19}
20
21/// Generate a type-safe, async HTTP client from endpoint definitions.
22///
23/// See the [crate-level docs](crate) for the full endpoint grammar and features
24/// (auth, retries, path/query params, headers, custom method names).
25#[proc_macro]
26pub fn beckon(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
27    expand_macro(input)
28}