floxide_macros/lib.rs
1use proc_macro::TokenStream;
2
3mod merge;
4mod node;
5mod workflow;
6
7/// Define a Workflow with fields and edges in one macro invocation.
8///
9/// Syntax:
10/// workflow! {
11/// pub struct Name { field1: Type1, field2: Type2, }
12/// context = MyCtx;
13/// start = field1;
14/// edges {
15/// field1 => [field2];
16/// field2 => [];
17/// };
18/// }
19#[proc_macro]
20pub fn workflow(item: TokenStream) -> TokenStream {
21 workflow::workflow(item)
22}
23
24/// Define a Node with fields and a process body in one macro invocation.
25///
26/// Syntax:
27/// node! {
28/// pub struct Name { field1: Type1, field2: Type2, }
29/// context = MyCtx;
30/// input = InputType;
31/// output = OutputType;
32/// |ctx, input_val| { /* can access self, returns Result<Transition<OutputType>, FloxideError> */ }
33/// }
34#[proc_macro]
35pub fn node(item: TokenStream) -> TokenStream {
36 node::node(item)
37}
38/// Derive implementation for the `Merge` trait.
39///
40/// Automatically implements `Merge` by merging each field of a struct using its own `merge` method.
41#[proc_macro_derive(Merge)]
42pub fn derive_merge(item: TokenStream) -> TokenStream {
43 merge::derive(item)
44}