type-c-service: Migrate to async function calls#833
Merged
jerrysxie merged 10 commits intoMay 14, 2026
Merged
Conversation
0e41390 to
39cc831
Compare
Cargo Vet Audit Passed
|
de3f1b1 to
352e330
Compare
Transitioning away from the last bit of messaging code, no longer needed.
6e6e4b4 to
a4c73a2
Compare
a4c73a2 to
dd967cd
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Type-C service from a centralized Context + Bridge-based messaging architecture to direct async method calls on locked port objects. The Type-C service now operates over a generic Registration trait that exposes ports as &[&Port] and uses per-port event channels plus a new event receiver abstraction.
Changes:
- Delete the
bridgemodule and theservice::context::Contextrequest/response indirection; the service now callsPd/UcsiLpmtrait methods directly on locked ports. - Introduce
service::registration::{Registration, ArrayRegistration}andservice::event_receiver::ArrayEventReceiver; require port traits (Pd,Retimer,Controller,Lpm,SystemPowerStateStatus) to beNamed. - Carry a port reference (
&'port Port) inPortEvent/Eventinstead ofGlobalPortId, and splitEventfromEventData.
Reviewed changes
Copilot reviewed 41 out of 44 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| type-c-service/src/service/mod.rs | Replaces Context/cached port_status state with generic Registration; rewrites event types around port references |
| type-c-service/src/service/ucsi.rs | UCSI processing now operates on locked port refs; reorganized state fields |
| type-c-service/src/service/power.rs | Iterates over registration.ports() instead of using context; updates power policy event variant pattern |
| type-c-service/src/service/registration.rs | New Registration trait + ArrayRegistration implementation |
| type-c-service/src/service/event_receiver.rs | New ArrayEventReceiver / ArrayPortReceivers replacing old EventReceiver |
| type-c-service/src/service/vdm.rs | File removed (VDM helpers no longer routed through service) |
| type-c-service/src/task.rs | task is now generic over registration and the new event receiver |
| type-c-service/src/controller/*.rs | Port struct gains a TypeCSender, removes global_port/context; all trait impls updated |
| type-c-service/src/controller/macros.rs | Macro adds a Type-C event channel; create signature drops global port id and context |
| type-c-service/src/bridge/*.rs | Bridge module deleted |
| type-c-service/src/lib.rs | Remove pub mod bridge |
| type-c-interface/src/service/context.rs | Context module removed |
| type-c-interface/src/service/event.rs | PortEvent/Event now carry &'port Port; split into Event + EventData |
| type-c-interface/src/service/mod.rs | Drops pub mod context |
| type-c-interface/src/port/{pd,retimer,power}.rs | Traits require Named supertrait |
| type-c-interface/src/port/mod.rs | Drops Command/Response/Device types (no longer needed without bridge) |
| type-c-interface/src/port/event.rs | Adjust imports after port::mod slimming |
| type-c-interface/src/controller/{mod,pd,power,retimer}.rs | Traits require Named supertrait |
| type-c-interface/src/ucsi.rs | Lpm trait requires Named |
| type-c-interface/Cargo.toml | Drops embassy-sync/embassy-time deps no longer needed |
| examples/std/src/lib/type_c/mock_controller.rs | Adds name field and Named impl; Port type gains TypeCSender param |
| examples/std/src/bin/type_c/{service,ucsi,unconstrained}.rs | Update to new registration/event-receiver wiring; remove bridge tasks |
| examples/std/src/bin/type_c/basic.rs | Example removed |
| examples/std/Cargo.toml | Drops the type-c-basic binary |
| examples/rt685s-evk/src/bin/{type_c,type_c_cfu}.rs | Update example wiring; remove bridge task; second port now uses LocalPortId(1) |
| Cargo.lock / examples/*/Cargo.lock | Lockfile updates |
Continue moving away from context type. Application code must now setup communication channels between port code and the type-C service.
Any device should have a human readable name.
Remove most uses of this type, limited it mostly to the UCSI code. Service events now deal directly with referencs to port objects. Remove port state stored in service implementation.
dd967cd to
42ce430
Compare
jerrysxie
requested changes
May 14, 2026
kurtjd
approved these changes
May 14, 2026
tullom
approved these changes
May 14, 2026
jerrysxie
approved these changes
May 14, 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.
Contexttype, application code is now responsible for creating event senders/receiversGlobalPortIdusage