NLnetLabs / domain

A DNS library for Rust.
https://nlnetlabs.nl/projects/domain/about/
BSD 3-Clause "New" or "Revised" License
341 stars 57 forks source link

Change IANA types from an enum into a struct wrapping an integer. #273

Closed partim closed 5 months ago

partim commented 6 months ago

It occurred to me that the way IANA types are represented in base::iana is not great. Currently we have an enum with an Int variant for undefined values. But because the field of that variant is public, you can actually create an Int variant for a well-defined value which is weird at best and causes issues at worst.

Instead, we should probably have a type that (privately) wraps the underlying integer type and define associated constants for all the known variants.

Obviously, this is a massively breaking change but I think it is worth doing as it will make the code more robust. So, I’d like to do it with 0.10.0 already.