warframe_macros/
lib.rs

1mod model;
2
3use manyhow::manyhow;
4use proc_macro::TokenStream;
5
6/// This is a macro to model a worldstate (api) object.
7///
8/// Note that this macro will automatically put `#[serde(rename_all = "camelCase")]` on your struct.
9///
10/// Additionally, it will derive `Debug, Clone, PartialEq, PartialOrd, serde::Deserialize` for
11/// structs, and `Debug, PartialEq, PartialOrd, Clone, Eq, Copy, Hash, derive_more::Display` for
12/// enums.
13///
14/// # Args
15/// - `endpoint = "/endpoint"` the endpoint to request
16/// - `return_style = Array/Object` the JSON format returned by the API
17/// - `timed (= true/false)` defaults to false. Adds an `activation` / `expiry` field and implements
18///   [TimedEvent](../warframe/worldstate/trait.TimedEvent.html)
19#[manyhow]
20#[proc_macro_attribute]
21pub fn model(args: TokenStream, item: TokenStream) -> syn::Result<TokenStream> {
22    model::expand(args.into(), item.into()).map(Into::into)
23}