8000 uefi: Improve the VariableKey type and iterator by nicholasbishop · Pull Request #1424 · rust-osdev/uefi-rs · GitHub
[go: up one dir, main page]

Skip to content

uefi: Improve the VariableKey type and iterator #1424

New issue

Have a question abou 8000 t this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

nicholasbishop
Copy link
Member

Prior to this commit, the name field of VariableKey was not public, so it was not possible to construct VariableKey outside of this crate. This is a problem for unit tests that want to mock runtime::variable_keys; there's no way for the unit test to construct the iterator elements.

Fix by making name public. Also change the name type from a Vec<u16> to a CString16; this makes the type easier to work with, since in all cases variable names should be UCS-2. The VariableKeys iterator now yields an error for variables with non-UCS-2 names (but such errors do not stop iteration; you can simply continue on to the next variable key).

Also deprecate the VariableKey::name() method, since it just returns the same thing as the name field now.

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

Prior to this commit, the `name` field of `VariableKey` was not public, so it
was not possible to construct `VariableKey` outside of this crate. This is a
problem for unit tests that want to mock `runtime::variable_keys`; there's no
way for the unit test to construct the iterator elements.

Fix by making `name` public. Also change the `name` type from a `Vec<u16>` to a
`CString16`; this makes the type easier to work with, since in all cases
variable names should be UCS-2. The `VariableKeys` iterator now yields an error
for variables with non-UCS-2 names (but such errors do not stop iteration; you
can simply continue on to the next variable key).

Also deprecate the `VariableKey::name()` method, since it just returns the same
thing as the `name` field now.
Copy link
Member
@phip1611 phip1611 left a comment

Choose a reason for hiding this comment

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

LGTM!

@phip1611 phip1611 added this pull request to the merge queue Oct 7, 2024
Merged via the queue into rust-osdev:main with commit 19da496 Oct 7, 2024
14 checks passed
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.

2 participants
0