domain/rdata/
mod.rs

1//! Record Data of Well-defined Record Types
2//!
3//! This module will eventually contain implementations for the record data
4//! of all defined resource record types.
5//!
6//! The types are named identically to the
7//! [`domain::base::iana::Rtype`][crate::base::iana::Rtype] variant they
8//! implement. They are grouped into submodules for the RFCs they are defined
9//! in. All types are also re-exported at the top level here. Ie., for the
10//! AAAA record type, you can simply `use domain::rdata::Aaaa` instead of
11//! `use domain::rdata::rfc3596::Aaaa` which nobody could possibly
12//! remember. There are, however, some helper data types defined here and
13//! there which are not re-exported to keep things somewhat tidy.
14//!
15//! See the [`domain::base::iana::Rtype`][crate::base::iana::Rtype] enum for
16//! the complete set of record types and, consequently, those types that are
17//! still missing.
18//!
19//! In addition, the module provides two enums combining the known types.
20//! [`AllRecordData`] indeed contains all record data types known plus
21//! [`UnknownRecordData`] for the rest, while [`ZoneRecordData`] only
22//! contains those types that can appear in zone files plus, again,
23//! [`UnknownRecordData`] for everything else.
24
25// A note on implementing record types with embedded domain names with regards
26// to compression and canonical representation:
27//
28// RFC 3597 stipulates that only record data of record types defined in RFC
29// 1035 is allowed to be compressed. (These are called “well-known record
30// types.”) For all other types, `CompressDname::append_compressed_name`
31// must not be used and the names be composed with `ToDname::compose`.
32//
33// RFC 4034 defines the canonical form of record data. For this form, domain
34// names included in the record data of the following record types must be
35// composed canonically using `ToName::compose_canonical`: All record types
36// from RFC 1035 plus RP, AFSDB, RT, SIG, PX, NXT, NAPTR, KX, SRV, DNAME, A6,
37// RRSIG, NSEC. All other record types must be composed canonically using
38// `ToName::compose`.
39//
40// The macros module contains three macros for generating name-only record
41// types in these three categories: `name_type_well_known!` for types from
42// RFC 1035, `name_type_canonical!` for non-RFC 1035 types that need to be
43// lowercased, and `name_type!` for everything else.
44
45#[macro_use]
46mod macros;
47
48pub mod aaaa;
49pub mod cds;
50pub mod dname;
51pub mod dnssec;
52pub mod naptr;
53pub mod nsec3;
54pub mod rfc1035;
55pub mod srv;
56pub mod svcb;
57pub mod tsig;
58pub mod zonemd;
59
60// The rdata_types! macro (defined in self::macros) defines the modules
61// containing the record data types, re-exports those here, and creates the
62// ZoneRecordData and AllRecordData enums containing all record types that
63// can appear in a zone file and all record types that exist.
64//
65// All record data types listed here MUST have the same name as the
66// `Rtype` variant they implement – some of the code implemented by the macro
67// relies on that.
68//
69// Add any new module here and then add all record types in that module that
70// can appear in zone files under "zone" and all others under "pseudo".
71// Your type can be generic over an octet type "O" and a domain name type "N".
72// Add these as needed. Trait bounds on them differ for different methods, so
73// check the bounds on ZoneRecordData and AllRecordData if there are errors.
74rdata_types! {
75    rfc1035::{
76        zone {
77            A,
78            Cname<N>,
79            Hinfo<O>,
80            Mb<N>,
81            Md<N>,
82            Mf<N>,
83            Mg<N>,
84            Minfo<N>,
85            Mr<N>,
86            Mx<N>,
87            Ns<N>,
88            Ptr<N>,
89            Soa<N>,
90            Txt<O>,
91        }
92        pseudo {
93            Null<O>
94        }
95    }
96    aaaa::{
97        zone {
98            Aaaa,
99        }
100    }
101    cds::{
102        zone {
103            Cdnskey<O>,
104            Cds<O>,
105        }
106    }
107    dname::{
108        zone {
109            Dname<N>,
110        }
111    }
112    dnssec::{
113        zone {
114            Dnskey<O>,
115            Rrsig<O, N>,
116            Nsec<O, N>,
117            Ds<O>,
118        }
119    }
120    naptr::{
121        zone {
122            Naptr<O, N>,
123        }
124    }
125    nsec3::{
126        zone {
127            Nsec3<O>,
128            Nsec3param<O>,
129        }
130    }
131    srv::{
132        zone {
133            Srv<N>,
134        }
135    }
136    svcb::{
137        pseudo {
138            Svcb<O, N>,
139            Https<O, N>,
140        }
141    }
142    tsig::{
143        pseudo {
144            Tsig<O, N>,
145        }
146    }
147    zonemd::{
148        zone {
149            Zonemd<O>,
150        }
151    }
152}