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

Redesign `CharStr` formatting and serialization. #270

Closed partim closed 7 months ago

partim commented 7 months ago

This PR redesigns the conversion of CharStr from and to text formats.

It distinguishes between three text formats: quoted and unquoted representation format (i.e., what’s used in zonefiles) and a serialization format which is an unquoted format with only backslash and non-printable octets escaped. The latter will be used in serialization but also by default for Display. This makes it reversible with the FromStr implementation but avoids escaping white space. Methods for explicitly displaying in quoted and unquoted representation format are provided.

Serialization works mostly as before but uses the serialization format rather than the unquoted representation format in human-readable formats. It still uses the raw octets in binary formats.

The PR adds proper documentation for all of it to the type.

This is a breaking change.