mirror of
https://github.com/NLnetLabs/domain.git
synced 2026-09-23 10:15:00 +02:00
This commit swaps the traits and types defined in `base::octets` for their equivalent in the `octseq` trait. These are mostly the same except that they facilitate Generic Associated Types as stabilized in Rust 1.65. This results in subtly changed trait bounds, though mostly these should be invisible to the user. One notable change is that `octseq` makes the error type of the `OctetsBuilder` generic and uses `Infallible` for those types where appending data will never fail (which, for most users, is all of them). It provides methods for either case and we are mirroring these in `domain`. While this means that converting you code to using the PR will require some work, that work should mostly be removing unwraps – which is nice. We’re using the opportunity to clean up a few more things that have crept into the code over time. A list of which will be added here: * The range, slice, and split methods on the domain name types have changed. They have been merge into a single method taking ranges – except for those on `Dname` that require type changes. The split methods now take references and don’t change `self` anymore. This is somewhat required by the limitations imposed by the new `Octets` trait but feels better, anyway. * The `Parse`, `Compose`, and `Scan` traits have been demoted to mere extension traits for foreign types (primarily the built-in integers, so that you can do things like `u16::parse`). All other types now simply have methods matching the patterns. Where generics are necessary, dedicated traits have been added. E.g., there now are `ParseRecordData` and `ComposeRecordData` traits that are implemented by all record data types. * Composing of record data and options has been switched to a scheme where the size is predetermined whenever possible instead of composing the data and then updating the length after. Since this is not possible for record data that uses compressed names when compression is actually in use, the old scheme is still used in this particular case.