Skip to main content

girolle_macro/
lib.rs

1use proc_macro::TokenStream;
2mod entry;
3
4/// #girolle macro
5///
6/// ## Description
7///
8/// girolle macro is used to generate a complexe tree function.
9/// - The first function is a copy of the original function with a suffix `_core`.
10/// - The second one is just a wrapper to deserialize the input and serialize the output
11///   with serde_json.
12/// - The thrid one is the creation of the RpcTask.
13///
14/// `type NamekoFunction = fn(&[Value]) -> Result<Value>`
15///
16/// It support the serde serialization types.
17/// ```rust,no_run
18/// use serde_json::{Number, Map};
19///
20/// enum Value {
21///    Null,
22///    Bool(bool),
23///    Number(Number),
24///    String(String),
25///    Array(Vec<Value>),
26///    Object(Map<String, Value>),
27///}
28/// ```
29/// The function must be deterministic, which means that it must always return a serializable result.
30#[proc_macro_attribute]
31pub fn girolle(_metadata: TokenStream, input: TokenStream) -> TokenStream {
32    entry::girolle_task(input.into()).into()
33}