workflow_core_macros/
lib.rs

1use proc_macro::TokenStream;
2// mod attribute_cleaner;
3mod enums;
4mod seal;
5mod send;
6
7///
8/// Attribute macro for automatic conversion of enums to their string representation
9///
10/// This macro works only with pure enums (it does not support enums that have
11/// values represented as structs)
12///
13/// This macro implements the following methods:
14///
15/// ```ignore
16/// // returns a Vec of all enum permutations
17/// fn list() -> Vec<MyEnum>;
18/// // returns the `rustdoc` description of the enum
19/// fn descr(&self) -> &'static str;
20/// // return the name of the value i.e. `Value`
21/// fn as_str(&self) -> &'static str;
22/// // return the the namespaced enum value i.e. `MyEnum::Value`
23/// fn as_str_ns(&self)->&'static str;
24/// // get enum value from the name i.e. `Value`
25/// fn from_str(str:&str)->Option<MyEnum>;
26/// // get enum value from the namespaced value name i.e. `MyEnum::Value`
27/// fn from_str_ns(str:&str)->Option<#enum_name>;
28/// ```
29///
30///
31#[proc_macro_derive(Describe, attributes(caption, describe))]
32pub fn describe_enum(item: TokenStream) -> TokenStream {
33    enums::macro_handler(item)
34}
35
36#[proc_macro]
37pub fn seal(input: TokenStream) -> TokenStream {
38    seal::seal(input)
39}
40
41#[proc_macro]
42pub fn call_async_no_send(input: TokenStream) -> TokenStream {
43    send::call_async_no_send(input)
44}
45
46// #[proc_macro_attribute]
47// pub fn clean_attributes(_attr: TokenStream, item: TokenStream) -> TokenStream {
48//     attribute_cleaner::clean_attributes(_attr, item)
49// }