rusty_gasket_macros/lib.rs
1//! Procedural macros for the Rusty Gasket framework.
2//!
3//! Currently provides `#[derive(ApiError)]` for generating [`ApiError`]
4//! trait implementations and `IntoResponse` conversions from annotated
5//! enum variants.
6
7use proc_macro::TokenStream;
8
9mod api_error;
10
11/// Derive macro for the `ApiError` trait.
12///
13/// Each enum variant must be annotated with `#[api_error(code = "...", status = ...)]`.
14/// An optional `expose = true/false` controls whether the error message is
15/// sent to the client (defaults to `true` for 4xx, `false` for 5xx).
16///
17/// Also generates an `IntoResponse` implementation that produces
18/// standardized JSON error bodies via `error_into_response`.
19#[proc_macro_derive(ApiError, attributes(api_error))]
20pub fn derive_api_error(input: TokenStream) -> TokenStream {
21 api_error::derive(input)
22}