type-c-service: Remove interior mutability from service#766
Open
RobertZ2011 wants to merge 3 commits intoOpenDevicePartnership:v0.2.0from
Open
type-c-service: Remove interior mutability from service#766RobertZ2011 wants to merge 3 commits intoOpenDevicePartnership:v0.2.0from
RobertZ2011 wants to merge 3 commits intoOpenDevicePartnership:v0.2.0from
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the host↔EC communication path (notably eSPI) toward a direct async “relay” model, and decouples several services’ wire/message types into dedicated *-messages crates to improve composability and testability.
Changes:
- Introduces a generic MCTP relay framework (
embedded-service::relay) and updates eSPI service to use it. - Splits debug/battery message types into new
debug-service-messages/battery-service-messagescrates and updates services accordingly. - Updates examples/workspace/CI to account for new crates, features, and adds coverage reporting in GitHub Actions.
Reviewed changes
Copilot reviewed 33 out of 43 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/std/Cargo.toml | Updates deps/features to use new interface/message crates and newer battery async crate; removes an example bin. |
| examples/rt685s-evk/Cargo.toml | Adds new interface/common deps needed by refactored services. |
| examples/rt685s-evk/.cargo/config.toml | Reformats rustflags and lowers default DEFMT_LOG verbosity. |
| examples/rt633/Cargo.toml | Tidies embassy-sync features; bumps battery crate and bq40z50-rx versions; adds power-policy interface. |
| examples/pico-de-gallo/Cargo.toml | Adds a new standalone example workspace with updated deps. |
| espi-service/src/task.rs | Removes old task entrypoint in favor of the new runner-based service structure. |
| espi-service/src/lib.rs | Gates eSPI module for tests and re-exports new implementation. |
| espi-service/src/espi_service.rs | Major refactor: introduces Resources/Runner and integrates relay handler for request/response. |
| espi-service/Cargo.toml | Adds deps to support relay/bitfield/num_enum and runnable-service integration. |
| embedded-service/src/type_c/mod.rs | Removes old Type-C service module from embedded-service crate. |
| embedded-service/src/type_c/external.rs | Removes old external Type-C command/message definitions. |
| embedded-service/src/relay/mod.rs | Adds generic relay + MCTP header/message macro to support direct async relay services. |
| embedded-service/src/power/policy/policy.rs | Removes old in-crate power policy implementation. |
| embedded-service/src/power/policy/mod.rs | Removes old power policy public API/types. |
| embedded-service/src/power/policy/device.rs | Removes old power policy device state machine. |
| embedded-service/src/power/policy/charger.rs | Removes old power policy charger integration. |
| embedded-service/src/power/policy/action/policy.rs | Removes old policy action type-state API. |
| embedded-service/src/power/policy/action/mod.rs | Removes old policy action module entry. |
| embedded-service/src/power/policy/action/device.rs | Removes old device action type-state API. |
| embedded-service/src/power/mod.rs | Removes old power module entry. |
| embedded-service/src/named.rs | Adds a small Named trait utility. |
| embedded-service/src/lib.rs | Updates module exports and adds hidden macro re-exports used by relay macro. |
| embedded-service/src/event.rs | Adds generic sender/receiver abstractions over embassy channels/pubsub. |
| embedded-service/src/ec_type/structure.rs | Removes old EC memory map structure definitions. |
| embedded-service/src/ec_type/protocols/mptf.rs | Removes protocol enum definitions from embedded-service crate. |
| embedded-service/src/ec_type/protocols/mod.rs | Removes protocol module tree from embedded-service crate. |
| embedded-service/src/ec_type/protocols/debug.rs | Removes debug protocol enum definitions from embedded-service crate. |
| embedded-service/src/ec_type/protocols/acpi.rs | Removes ACPI protocol enum definitions from embedded-service crate. |
| embedded-service/src/ec_type/message.rs | Removes old host message/request envelope types from embedded-service crate. |
| embedded-service/src/ec_type/generator/ec_memory_map.yaml | Removes old EC memory map generator input. |
| embedded-service/src/ec_type/generator/ec-memory-generator.py | Removes old EC memory map generator script. |
| embedded-service/src/comms.rs | Tightens message payload bounds to Any + Send + Sync and removes a TimeAlarm endpoint. |
| embedded-service/src/cfu/mod.rs | Removes old in-crate CFU client implementation. |
| embedded-service/Cargo.toml | Adjusts deps to support relay/macro infra and target cfg changes. |
| docs/api-guidelines.md | Adds service API guidelines aligned with resources/runner/traits patterns. |
| debug-service/src/task.rs | Refactors debug service tasks to use message crate + signals rather than comms to host. |
| debug-service/src/lib.rs | Gates debug service on not(test) to avoid desktop build issues. |
| debug-service/src/debug_service.rs | Converts Debug service into an MCTP relay handler using debug-service-messages. |
| debug-service/Cargo.toml | Adds debug-service-messages dep and feature wiring. |
| debug-service-messages/src/lib.rs | New message crate defining debug request/response/error serialization. |
| debug-service-messages/Cargo.toml | New crate manifest for debug message types. |
| cfu-service/src/task.rs | Removes internal singleton init; task now takes a provided CFU client instance. |
| cfu-service/src/splitter.rs | Refactors CFU splitter routing to use CfuClient context instead of embedded-service CFU module. |
| cfu-service/src/lib.rs | Re-homes CFU client context into cfu-service and adds init/registration helpers. |
| cfu-service/src/component.rs | Updates component processing to route requests via CfuClient. |
| cfu-service/src/buffer.rs | Updates buffering logic to route/send/wait via CfuClient context. |
| battery-service/src/task.rs | Changes task init flow: registers devices, returns structured init errors. |
| battery-service/src/mock.rs | Adds mock battery implementation to support host/std testing. |
| battery-service/src/lib.rs | Converts battery ACPI handling to relay handler types and modernizes APIs. |
| battery-service/src/device.rs | Switches DeviceId to message-crate definition. |
| battery-service/src/context.rs | Converts ACPI request processing to typed requests/results; starts migration off comms for power policy updates. |
| battery-service/src/acpi.rs | Reworks ACPI handlers to return typed AcpiBatteryResponse results. |
| battery-service/Cargo.toml | Adds message crate + power-policy interface dep; introduces mock feature. |
| battery-service-messages/Cargo.toml | New crate manifest for battery message types. |
| Cargo.toml | Adds new workspace members and workspace deps for interfaces/messages/common crates. |
| .vscode/settings.json | Adds new example manifest to TOML schema associations. |
| .github/workflows/check.yml | Adds coverage instrumentation + grcov report generation and checks new example workspace. |
| .github/workflows/cargo-vet.yml | Bumps cargo-vet version and forces stable toolchain for install. |
456a40b to
55aaa45
Compare
55aaa45 to
7d95c3a
Compare
7d95c3a to
1c322f7
Compare
kurtjd
reviewed
Apr 1, 2026
1c322f7 to
07aa6e3
Compare
kurtjd
approved these changes
Apr 1, 2026
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.
Uh oh!
There was an error while loading. Please reload this page.