RFC: use `core::net` IP address types in `uefi`'s public API
Closed this issue · 2 comments
Currently, we provide the following IP address types:
-
uefi-raw:struct Ipv4Address- 4 raw bytesstruct Ipv6Address- 16 raw bytesunion IpAddress- untagged union, can be either v4 or v6 address, but no way to tell without out-of-band data
-
uefi:struct IpAddress- 16 raw bytes. Compatible with theuefi_raw::IpAddressunion, but implemented differently. No way to tell which type of address it is without out-of-band data
-
And these builtin types are in
core::net:struct Ipv4Addr- opaque struct, but essentially 4 raw bytesstruct Ipv6Addr- opaque struct, but essentially 16 raw bytesenum IpAddr- tagged enum containing eitherIpv4AddrorIpv6Addr
The types in uefi-raw correctly match the spec, so there's nothing we need to change there.
In uefi however, I think it might make sense to switch to the core::net types in the public API, and drop our IpAddress. The core::net types are not ABI-compatible with the UEFI types, so internally we'll need to translate between them. This should be a very low-cost operation though.
Using the IpAddr enum provides a better experience than using an untagged enum that requires a separate flag to indicate which type of address it contains. We could define our own enum of course, but using core::net makes it easier to integrate with other Rust code by using a shared type.
This change would be an API break, but it only affects a fairly small part of the library (the SimpleNetwork and pxe::BaseCode protocols).
Yep, sounds good! Thanks for the write-up