1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/// Derive macro that generates an MPSC channel helper struct for an enum.
///
/// The enum name must contain "Event" (e.g., `MyEvent`). The macro generates:
/// - A helper struct named `{Prefix}Helper` (e.g., `MyHelper` from `MyEvent`)
/// - A receiver type alias named `{EnumName}Receiver`
/// - Async send methods for each enum variant (names converted to snake_case)
/// - A `new(size)` constructor returning `(Helper, Receiver)` tuple
/// - A `From<mpsc::Sender>` impl for the helper struct
///
/// # Attributes
///
/// - `#[helper(block)]` on the enum or variant: also generate blocking send methods (suffixed with `_b`)
/// - `#[helper(no_async)]` on the enum or variant: generate only blocking send methods (no async)
///
/// # Example
///
/// ```rust,ignore
/// #[derive(Helper)]
/// enum MyEvent {
/// UserLogin { username: String },
/// UserLogout,
/// DataUpdate(Vec<u8>),
/// }
/// // Generates: MyHelper with async methods user_login(), user_logout(), data_update()
/// ```
/// Procedural macro that generates a bit flag enum with checker methods.
///
/// Each variant is assigned a unique power-of-two value (`1 << index`), and a
/// corresponding `is_{snake_case_name}()` method is generated on the enum.
///
/// The macro also derives `Clone`, `Copy`, and `Debug` for the generated enum.
///
/// # Example
///
/// ```rust,ignore
/// bit_helper! {
/// enum Features {
/// Analytics, // = 1
/// Notifications, // = 2
/// DarkMode, // = 4
/// }
/// }
/// // Generates: Features with methods is_analytics(), is_notifications(), is_dark_mode()
/// ```
/// Procedural macro that generates an MPSC helper with request-response support
/// via oneshot channels.
///
/// Similar to `#[derive(Helper)]`, but variants annotated with `#[ret(Type)]` will
/// have their generated methods return `Option<Type>` instead of `Option<()>`. The
/// macro automatically injects a `tokio::sync::oneshot::Sender` field into each
/// annotated variant and manages the oneshot channel lifecycle.
///
/// Variants without `#[ret(...)]` behave identically to the basic `Helper` derive.
///
/// The enum is re-emitted with the additional sender fields, so it must be used
/// as `oneshot_helper! { ... }` rather than as a derive macro.
///
/// # Example
///
/// ```rust,ignore
/// oneshot_helper! {
/// enum QueryEvent {
/// #[ret(String)]
/// GetConfig { key: String },
/// #[ret(bool)]
/// IsEnabled { feature: &'static str },
/// Shutdown,
/// }
/// }
/// // Generates: QueryHelper with methods:
/// // async fn get_config(&self, key: String) -> Option<String>
/// // async fn is_enabled(&self, feature: &'static str) -> Option<bool>
/// // async fn shutdown(&self) -> Option<()>
/// ```