Skip to content
New issue

Have a question about 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

Study other enums in uefi-rs #53

Closed
HadrienG2 opened this issue Sep 27, 2018 · 1 comment
Closed

Study other enums in uefi-rs #53

HadrienG2 opened this issue Sep 27, 2018 · 1 comment
Labels

Comments

@HadrienG2
Copy link
Contributor

HadrienG2 commented Sep 27, 2018

It is well possible that #48 was just the tip of the iceberg, and that we need to rethink the way we handle enums in FFI. To check if this is the case, we should take a tour of the various enums in uefi-rs and determine if...

  • The spec might add new enum variants in the future and expose them to us without us asking for it.
  • Implementations are allowed to add new enum variants if they feel so inclined.

If the answer to either of these questions is "yes" or even "I don't know", then the enum must be replaced with an integer newtype as was done for Status.

@HadrienG2 HadrienG2 changed the title Study other enums in the uefi-rs Study other enums in uefi-rs Sep 27, 2018
@HadrienG2
Copy link
Contributor Author

I took a look around. There are two other C enums in the crate which should not be modeled as Rust enums:

  • The ScanCode enum of the Input protocol has a range of values reserved for extensibility, therefore it is designed to allow unexpected variants.
  • The ProcessorArch enum of the DebugSupport protocol is also subjected to further extensions. UEFI can be and has been ported to new CPU architectures, most recently RISC-V.

I am able to formulate a rough rationale of why the other enums involved in FFI look safe to me, which I have written down in code as comments (since that information is critical to the type-safety of uefi-rs, it seems best to have it in the code). A PR will follow shortly once I have sorted out the two issues above (most likely by generalizing the macromancy that I have introduced for Status).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant