Skip to content

ucsi/lpm: Add iterator over GET_PDOS content#51

Merged
RobertZ2011 merged 2 commits intoOpenDevicePartnership:mainfrom
RobertZ2011:get-pdos-iterator
Sep 24, 2025
Merged

ucsi/lpm: Add iterator over GET_PDOS content#51
RobertZ2011 merged 2 commits intoOpenDevicePartnership:mainfrom
RobertZ2011:get-pdos-iterator

Conversation

@RobertZ2011
Copy link
Copy Markdown
Contributor

@RobertZ2011 RobertZ2011 commented Sep 23, 2025

  • Also fix PDO count
  • Add PDO length constant

Breaking due to making raw private, iterators can be used to access contents now.

* Also fix PDO count
* Add PDO length constant
@RobertZ2011 RobertZ2011 self-assigned this Sep 23, 2025
@RobertZ2011 RobertZ2011 marked this pull request as ready for review September 23, 2025 22:17
@RobertZ2011 RobertZ2011 requested a review from a team as a code owner September 23, 2025 22:17
Copy link
Copy Markdown
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 adds an iterator interface to the GET_PDOS response data and fixes the PDO count calculation to comply with the UCSI specification. The changes improve the API ergonomics by providing safe iteration over PDO data while ensuring correct specification compliance.

  • Fixed PDO count calculation by adding/subtracting 1 to match UCSI spec requirements
  • Added iterator methods (iter, iter_mut, len, is_empty) to ResponseData for convenient PDO traversal
  • Added PDO_LEN constant for better code maintainability

Reviewed Changes

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

File Description
src/ucsi/lpm/get_pdos.rs Fixed PDO count calculation, added iterator interface to ResponseData, and updated error handling
src/pdo/mod.rs Added PDO_LEN constant for standardized PDO size definition

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/ucsi/lpm/get_pdos.rs Outdated
Comment thread src/ucsi/lpm/get_pdos.rs Outdated
asasine
asasine previously approved these changes Sep 23, 2025
Copy link
Copy Markdown

@asasine asasine left a comment

Choose a reason for hiding this comment

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

non-blocking

Comment thread src/ucsi/lpm/get_pdos.rs Outdated
tullom
tullom previously approved these changes Sep 23, 2025
@RobertZ2011 RobertZ2011 dismissed stale reviews from tullom and asasine via dd9f7a9 September 23, 2025 23:03
Copy link
Copy Markdown

@tullom tullom left a comment

Choose a reason for hiding this comment

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

Love to see the unit tests 😄

@RobertZ2011 RobertZ2011 merged commit 98ca3ab into OpenDevicePartnership:main Sep 24, 2025
10 checks passed
asasine pushed a commit to OpenDevicePartnership/embedded-services that referenced this pull request Sep 24, 2025
Breaking change due to the new trait function.

Depends on:

- [x] OpenDevicePartnership/embedded-usb-pd#51
- [x] OpenDevicePartnership/tps6699x#75

---------

Co-authored-by: Adam Sasine <adam.sasine@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants