On Tue, Oct 21, 2025 at 08:21:19PM +0200, Philip Homburg wrote:
> > This type of extensibilty DOES NOT complicate APIs except for
> > DNS-utility applications like "dig", ... that choose to dabble in
> > processing of ad hoc query results.
>
> Maybe it's a language thing. Our library (domain crate) supports low level
> operations on DNS messages (which are obviously open-ended both with
> respect to new Rtypes and new EDNS(0) options) and higher level resolver
> constructs.
>
> However, for the user of the library this is most often not a problem.
> A Rust 'enum' provides the user of the library with direct access to all
> supported types. If the type is not supported then the user gets a collection
> of bytes. The same applies to the SVCB/HTTPS parameters.
If one accepts freezing all the structures at point in time known
variants, then sure, no problem. But that does not make for a stable
API as extensions happen. Nor does that support pluggable
application-supplied extensions for variants not yet known to the
underlying library.
> Does the language you use have a sum type that has a hard time expressing
> unknown data?
The Haskell type system is notieably richer than that of Rust, the main
area where Rust is ahead is "linear" types, which in Haskell are new,
still evolving, and mostly marginal at present.
"Sum" types are not a good model for types that are extensible, because
the intoduction of new constructors is an API change: previosly
"complete" matches, become incomplete when a new variant is added.
> In domain crate, the application can also bring it's own types if it wants
> to support more types than currently supported in domain.
Does that include support for SVCB or HTTPs keys and associated value
types that were not known to the library, while not having to override
handleing of the RRTYPE as a whole (leaving known key/value pairs
untouched)?
How would a new "type 4" AMTRELAY be handled? Today we have:
data AmtRelay = Amt_Empty
| Amt_A IPv4
| Amt_AAAA IPv6
| Amt_Host Domain
| Amt_Opaque Word8 ByteString
What happens when an AMT_Foo with type 4 shows up, this changes
the type to:
data AmtRelay = Amt_Empty
| Amt_A IPv4
| Amt_AAAA IPv6
| Amt_Host Domain
| Amt_Foo Foo_info
| Amt_Opaque Word8 ByteString
This breaks extant "case" statements:
case relay of
Amt_Empty -> ...
Amt_A a -> ...
Amt_AAAA a -> ...
Amt_Host h -> ...
Amt_Opaque t bs -> ...
which now has a missing case.
--
Viktor. 🇺🇦 Слава Україні!
_______________________________________________
DNSOP mailing list -- [email protected]
To unsubscribe send an email to [email protected]