Power policy event pass and clean-up#747
Power policy event pass and clean-up#747RobertZ2011 wants to merge 9 commits intoOpenDevicePartnership:v0.2.0from
Conversation
Rename the current `'a` lifetime to `'device` for clarity. Introduce a separate `device_storage` lifetime since a single lifetime overconstrains things and can lead to situations where borrows live too long and lead to issues with drops.
1ff2ae6 to
5b931a9
Compare
There was a problem hiding this comment.
Pull request overview
This PR reintroduces power-policy service event broadcasting and refactors naming by introducing a shared Named trait, updating PSU implementations accordingly, and adding/expanding tests to validate provider and unconstrained behavior.
Changes:
- Add
embedded_services::named::Namedand updatePsuto requireNamedinstead of definingname()directly. - Add power-policy service event broadcasting via configurable event senders, plus introduce
EventDatafor device-agnostic service events. - Add/expand power-policy service integration tests for consumer/provider/unconstrained flows.
Reviewed changes
Copilot reviewed 15 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| type-c-service/src/wrapper/proxy.rs | Implements Named for PowerProxyDevice to satisfy updated Psu: Named bound. |
| power-policy-service/tests/unconstrained.rs | Adds unconstrained multi-device flow test using service event receiver assertions. |
| power-policy-service/tests/provider.rs | Adds provider connection/upgrade behavior tests and validates service events. |
| power-policy-service/tests/consumer.rs | Updates consumer tests to validate service-level events instead of only mock calls. |
| power-policy-service/tests/common/mod.rs | Extends test harness to provide a service event channel/receiver and adds assertion helpers. |
| power-policy-service/tests/common/mock.rs | Updates mock PSU simulation API and implements Named for the mock device. |
| power-policy-service/src/service/task.rs | Updates task generics to support event broadcasting sender types. |
| power-policy-service/src/service/provider.rs | Moves/expands provider disconnect handling into provider module and broadcasts provider events. |
| power-policy-service/src/service/mod.rs | Adds event_senders and implements broadcast_event; updates detach/disconnect flows accordingly. |
| power-policy-service/src/service/consumer.rs | Updates service impl generics and uses Named for logging. |
| power-policy-service/Cargo.toml | Comment formatting tweak. |
| power-policy-interface/src/service/event.rs | Adds EventData and From<Event> conversion; renames generics to PSU. |
| power-policy-interface/src/psu/mod.rs | Changes Psu to extend Named and removes fn name() from Psu. |
| examples/std/src/bin/type_c/unconstrained.rs | Updates power-policy service construction to pass event sender storage (currently discard). |
| examples/std/src/bin/type_c/ucsi.rs | Updates power-policy service task signature and adds discard event sender storage. |
| examples/std/src/bin/type_c/service.rs | Updates power-policy service construction to pass event sender storage (discard). |
| examples/std/src/bin/power_policy.rs | Updates example PSU to implement Named and passes discard event sender storage. |
| examples/rt685s-evk/src/bin/type_c_cfu.rs | Updates power-policy service task signature and adds discard event sender storage. |
| examples/rt685s-evk/src/bin/type_c.rs | Updates power-policy service task signature and adds discard event sender storage. |
| embedded-service/src/named.rs | Introduces Named trait. |
| embedded-service/src/lib.rs | Exposes named module. |
| embedded-service/src/event.rs | Adds DiscardSender and MapSender utilities for event sending pipelines. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
A receiver might only care that an event has happened and not what PSU generated the event. Currently, such a receiver would have to be generic over a PSU type that it never uses. Introduce `EventData` as a version of `Event` for use in these cases. Also rename `D` generic argument to `PSU` for clarity.
Rename for clarity.
Add event broadcasting based on `Sender<_>` trait, a few utility structs, and update tests to check broadcast events.
5b931a9 to
50c4c4b
Compare
50c4c4b to
44539e4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 22 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
44539e4 to
ceef927
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 22 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| } | ||
|
|
||
| /// A sender that discards all events sent to it. | ||
| pub struct DiscardSender; |
There was a problem hiding this comment.
minor nit: I think NoopSender might be a slightly preferrable name here and matches conventions other crates use (e.g. NoopRawMutex in embassy). Makes it clear it's just a type meant to satisfy the type system but doesn't do anything.
Namedtrait