Skip to content

Power policy event pass and clean-up#747

Open
RobertZ2011 wants to merge 9 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011:power-policy-event-refactor
Open

Power policy event pass and clean-up#747
RobertZ2011 wants to merge 9 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011:power-policy-event-refactor

Conversation

@RobertZ2011
Copy link
Contributor

@RobertZ2011 RobertZ2011 commented Mar 12, 2026

  • Add broadcasting power policy service events back
  • Introduce Named trait
  • Add provider tests
  • Add unconstrained logic test
  • General clean-up

@RobertZ2011 RobertZ2011 self-assigned this Mar 12, 2026
Copilot AI review requested due to automatic review settings March 12, 2026 21:23
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.
@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from 1ff2ae6 to 5b931a9 Compare March 12, 2026 21:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::Named and update Psu to require Named instead of defining name() directly.
  • Add power-policy service event broadcasting via configurable event senders, plus introduce EventData for 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.
Add event broadcasting based on `Sender<_>` trait, a few utility
structs, and update tests to check broadcast events.
@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from 5b931a9 to 50c4c4b Compare March 12, 2026 21:53
Copilot AI review requested due to automatic review settings March 12, 2026 22:00
@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from 50c4c4b to 44539e4 Compare March 12, 2026 22:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@RobertZ2011 RobertZ2011 force-pushed the power-policy-event-refactor branch from 44539e4 to ceef927 Compare March 12, 2026 22:14
@RobertZ2011 RobertZ2011 marked this pull request as ready for review March 12, 2026 23:06
@RobertZ2011 RobertZ2011 requested review from a team as code owners March 12, 2026 23:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants