Skip to content

power-policy-interface: Port disconnect reasons from v0.1 - #948

Open
RobertZ2011 wants to merge 3 commits into
OpenDevicePartnership:mainfrom
RobertZ2011:disconnect-flag-changes
Open

power-policy-interface: Port disconnect reasons from v0.1#948
RobertZ2011 wants to merge 3 commits into
OpenDevicePartnership:mainfrom
RobertZ2011:disconnect-flag-changes

Conversation

@RobertZ2011

@RobertZ2011 RobertZ2011 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Port changes from v0.1 that introduce an enum for disconnect reasons instead of separate flags. Also refactor existing power policy flag structs to use normal Rust structs instead of bitfield representations.

@RobertZ2011 RobertZ2011 self-assigned this Aug 21, 2026
@RobertZ2011
RobertZ2011 force-pushed the disconnect-flag-changes branch 3 times, most recently from 95095a0 to 72ce097 Compare August 24, 2026 20:30
@RobertZ2011 RobertZ2011 changed the title Disconnect flag changes power-policy-interface: Port disconnect reasons from v0.1 Aug 24, 2026
@RobertZ2011
RobertZ2011 force-pushed the disconnect-flag-changes branch 4 times, most recently from 9a747e5 to c7534ba Compare August 24, 2026 21:21
@RobertZ2011 RobertZ2011 added the BREAKING CHANGE Marks breaking changes label Aug 24, 2026
@RobertZ2011
RobertZ2011 force-pushed the disconnect-flag-changes branch from c7534ba to 60f8051 Compare August 24, 2026 21:27
@RobertZ2011
RobertZ2011 requested a lite review from Copilot August 24, 2026 21:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the power-policy interface and its consumers to replace legacy bitfield-style flags with normal Rust structs, and to model consumer disconnects using a structured DisconnectReason (wrapped in DisconnectFlags) rather than separate boolean flags. It also extends Type-C service behavior to propagate a hard-reset disconnect reason through the power-policy event path.

Changes:

  • Replace ConsumerDisconnect boolean flags with DisconnectFlags { reason: Option<DisconnectReason> } and update all notification/event plumbing accordingly.
  • Refactor ConsumerFlags/ProviderFlags from bitfield-backed types to plain Rust structs (and update tests/mocks/examples).
  • Add Type-C hard reset handling that tears down the current contract and emits a disconnect event with a reset reason (plus a new test covering it).

Reviewed changes

Copilot reviewed 22 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
type-c-service/tests/power.rs Updates tests to use struct-based flags and validates disconnect reasons (including new hard reset coverage).
type-c-service/tests/debug_accessory.rs Updates provider capability construction to the new ProviderFlags struct.
type-c-service/src/controller/power.rs Migrates capability flags to struct fields; emits structured disconnect reasons; adds hard reset teardown path.
type-c-service/src/controller/mod.rs Routes pd_hard_reset status events into the new hard reset teardown handler.
type-c-service/src/controller/max_sink_voltage.rs Switches renegotiation disconnect signaling to DisconnectReason::ManualRenegotiation.
type-c-interface-mocks/tests/connect_disconnect.rs Updates expected capabilities to use struct-based flags.
type-c-interface-mocks/src/port/mod.rs Updates mock port state updates to use struct-based flags.
power-policy-service/tests/unconstrained.rs Updates consumer flag usage to struct defaults/fields.
power-policy-service/tests/provider.rs Updates provider flag usage to struct defaults.
power-policy-service/tests/consumer.rs Updates disconnect assertions to reason-based disconnects and refactors related test naming.
power-policy-service/tests/common/mod.rs Renames helper to assert disconnect “reason” via DisconnectFlags instead of legacy flags.
power-policy-service/src/service/mod.rs Updates notifier plumbing and disconnect processing to carry DisconnectFlags/DisconnectReason.
power-policy-service/src/service/consumer.rs Updates consumer selection/switch logic to produce a single disconnect reason and carry it through events.
power-policy-interface/src/service/notification.rs Updates service notifier trait to accept DisconnectFlags.
power-policy-interface/src/service/event.rs Updates service event payloads to use DisconnectFlags.
power-policy-interface/src/psu/notification.rs Updates PSU notifier/handler traits to accept DisconnectFlags.
power-policy-interface/src/psu/event.rs Updates PSU event payloads and notifier adapters to use DisconnectFlags.
power-policy-interface/src/charger/tests.rs Updates helper capability construction to use ConsumerFlags::default().
power-policy-interface/src/capability.rs Replaces bitfield-based flag types with plain structs and introduces DisconnectReason + DisconnectFlags.
power-policy-interface/Cargo.toml Drops bitfield/num_enum dependencies that were only needed for bitfield-based flags.
power-policy-interface-test-mocks/src/psu.rs Updates mock PSU to construct provider flags via Default and notify disconnects via DisconnectFlags.
examples/std/src/bin/power_policy.rs Updates example capability construction to struct-based consumer flags.
examples/std/Cargo.lock Removes bitfield/num_enum from the example’s resolved dependency set.
examples/rt685s-evk/Cargo.lock Removes bitfield/num_enum from the example’s resolved dependency set.
examples/pico-de-gallo/Cargo.lock Removes bitfield/num_enum from the example’s resolved dependency set.
Cargo.lock Removes bitfield/num_enum from the workspace resolved dependency set for power-policy-interface.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread type-c-service/src/controller/power.rs
Comment thread power-policy-service/src/service/consumer.rs Outdated
@RobertZ2011
RobertZ2011 force-pushed the disconnect-flag-changes branch from 60f8051 to bbee585 Compare August 24, 2026 22:08
Implement these flag structs as plain Rust structs. This reduces
complexity and the number of dependencies.
Port disconnect reasons from v0.1 branch.
@RobertZ2011
RobertZ2011 force-pushed the disconnect-flag-changes branch from bbee585 to 5587b7f Compare August 24, 2026 22:12
@RobertZ2011
RobertZ2011 marked this pull request as ready for review August 24, 2026 22:12
@RobertZ2011
RobertZ2011 requested review from a team as code owners August 24, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BREAKING CHANGE Marks breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants