New macro design & goodies that comes with that#24
Merged
zeenix merged 7 commits intolayerx-world:mainfrom Nov 25, 2025
Merged
Conversation
Collaborator
zeenix
commented
Nov 25, 2025
- Macro now operates on a module
- Abstract the user from signal & state change types
- Attribute to generate client-side setters
- Add an e2e testcase
- Bump version
This allows the macro to have a visibility on both the struct and the impl block and would enable us to improve the ergonomics of the API and add new API that's currently not possible due to the decoupling between the macro operating on the struct and impl block.
Instead provide methods to create streams for state changes.
There was a problem hiding this comment.
Pull request overview
This PR refactors the firmware-controller macro to operate on modules instead of separate struct and impl items, improving ergonomics and enabling better coordinated code generation. The changes abstract signal and state change types from users and introduce a new pub_setter attribute for generating client-side setters.
Key Changes
- Module-based macro design: The
#[controller]attribute now applies to a module containing both the struct and impl block, enabling coordinated processing - Client-side pub_setter generation: New
#[controller(publish(pub_setter))]attribute generates public setter methods on the client API - Comprehensive integration test: Added end-to-end test validating all controller features including state changes, signals, and pub_setters
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration.rs | New comprehensive integration test demonstrating controller functionality with state management, signals, and pub_setters |
| src/lib.rs | Refactored macro entry point to parse modules instead of individual struct/impl items |
| src/controller/mod.rs | New module expansion logic that validates and coordinates struct/impl processing |
| src/controller/item_struct.rs | Enhanced to return PublishedFieldInfo for coordinated impl processing and parse pub_setter attribute |
| src/controller/item_impl.rs | Added pub_setter channel generation, client methods, and stream getter methods for published fields and signals |
| README.md | Updated examples and documentation to reflect module-based usage and pub_setter feature |
| CLAUDE.md | Updated architecture documentation to describe module-based processing flow |
| Cargo.toml | Version bump to 0.3.0 and added dev dependencies for testing (futures std/executor, critical-section) |
| Cargo.lock | Updated lock file with new dependency versions and transitive dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Published fields can now have a client-side setter method if user asks for it through a new sub-attribute, `pub_setter`.
We're introducing breaking changes.
a918f01 to
8dbe58e
Compare
maxgr0
approved these changes
Nov 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.