You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+36-14Lines changed: 36 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@ This is a procedural macro crate that provides the `#[controller]` attribute mac
8
8
9
9
* A controller struct that manages peripheral state.
10
10
* Client API for sending commands to the controller.
11
-
* Signal mechanism for broadcasting events.
12
-
*Pub/sub system for state change notifications.
11
+
* Signal mechanism for broadcasting events (PubSubChannel).
12
+
*Watch-based subscriptions for state change notifications (yields current value first).
13
13
14
14
The macro is applied to a module containing both the controller struct definition and its impl block, allowing coordinated code generation of the controller infrastructure, client API, and communication channels.
15
15
@@ -52,18 +52,31 @@ The `expand_module()` function:
52
52
* Combines the generated code back into the module structure along with any other items.
53
53
54
54
Channel capacities and subscriber limits are also defined here:
**Signal methods** (marked with `#[controller(signal)]`):
77
90
* Methods have no body in the user's impl block.
91
+
* Uses `embassy_sync::pubsub::PubSubChannel` for broadcast.
78
92
* Generates method implementation that broadcasts to subscribers.
79
93
* Creates `<StructName><MethodName>` stream type and `<StructName><MethodName>Args` struct.
80
94
* Signal methods are NOT exposed in the client API (controller emits them directly).
81
95
82
-
The generated `run()` method contains a `select_biased!` loop that receives method calls from clients and dispatches them to the user's implementations.
96
+
**Getter/setter methods** (from struct field attributes):
97
+
* Receives getter/setter field info from struct processing.
98
+
* Generates client-side getter methods that request current field value.
99
+
* Generates client-side setter methods that update field value (and broadcast if published).
100
+
101
+
The generated `run()` method contains a `select_biased!` loop that receives method calls from
102
+
clients and dispatches them to the user's implementations.
83
103
84
104
### Utilities (`src/util.rs`)
85
105
Case conversion functions (`pascal_to_snake_case`, `snake_to_pascal_case`) used for generating type and method names.
@@ -97,5 +117,7 @@ Dev dependencies include `embassy-executor` and `embassy-time` for testing.
97
117
* Singleton operation: multiple controller instances interfere with each other.
98
118
* Methods must be async and cannot use reference parameters/return types.
99
119
* Maximum 16 subscribers per state/signal stream.
100
-
* Published fields must implement `Clone` and `Debug`.
101
-
* Streams must be continuously polled or notifications are missed.
120
+
* Published fields must implement `Clone`.
121
+
* Published field streams yield current value on first poll; intermediate values may be missed if
122
+
not polled between changes.
123
+
* Signal streams must be continuously polled or notifications are missed.
0 commit comments