-
-
Notifications
You must be signed in to change notification settings - Fork 171
uefi-raw: move types to new net module, improve convenience #1699
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
base: main
Are you sure you want to change the base?
Conversation
We have enough network-related types to justify a dedicated module: - IpAddress - Ipv4Address - Ipv6Address - MacAddress And lots of corresponding impl{} blocks, tests, etc.
The union makes some things hard to work with, and we can simply remove it. We get multiple advantages from that: - no more chance to have uninitialized bytes - We can `Debug`-print the type - Some implementations become simpler
This helps to better understand why something fails.
check-raw is very strict. Relaxing it gives uefi-raw more freedom, which is especially needed for the more high-level IpAddress type changes.
|
||
## Changed | ||
- Types `MacAddress`, `IpAddress`, `Ipv4Address`, and `Ipv6Address` were moved | ||
from `uefi_raw::*` to `uefi_raw::net::*`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think moving the implementation to a new module makes sense, but I think for the public API it might make sense to let that be an internal detail, i.e. keep the net
module private and pub-export the types from the crate root. These types are listed in the Common UEFI Data Types portion of the spec, which to mind means they fit best at the top level (and this would also avoid making the change API breaking).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, makes sense!
This prepares my vision for #1575, a split-out from #1645, and a change to uefi-raw in the sense that some types now have slightly more higher-level logic. This "higher-level" logic is still low-level enough that I think it is perfectly fine to keep it. It will also not hinder Rust-based UEFI implementations.
TL;DR: My vision is that in
uefi
we only exposecore::net::{IpAddr, Ipv4Addr, Ipv6Addr}
and protocol implementations can useFrom/Into
to do all the necessary work under the hood.Let me know what you think!
List of Changes
IpAddress
type to be more convenient, more memory-safe, and pleasant to useFrom
implementationscargo xtask check-raw
requirementsChecklist