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 simple `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`][crate::base::rdata::UnknownRecordData] for the
22//! rest, while [`ZoneRecordData`] only
23//! contains those types that can appear in zone files plus, again,
24//! [`UnknownRecordData`][crate::base::rdata::UnknownRecordData] for
25//! everything else.
26
27// A note on implementing record types with embedded domain names with regards
28// to compression and canonical representation:
29//
30// RFC 3597 stipulates that only record data of record types defined in RFC
31// 1035 is allowed to be compressed. (These are called “well-known record
32// types.”) For all other types, `CompressDname::append_compressed_dname`
33// must not be used and the names be composed with `ToDname::compose`.
34//
35// RFC 4034 defines the canonical form of record data. For this form, domain
36// names included in the record data of the following record types must be
37// composed canonically using `ToDname::compose_canonical`: All record types
38// from RFC 1035 plus RP, AFSDB, RT, SIG, PX, NXT, NAPTR, KX, SRV, DNAME, A6,
39// RRSIG, NSEC. All other record types must be composed canonically using
40// `ToDname::compose`.
41//
42// The macros module contains three macros for generating name-only record
43// types in these three categories: `dname_type_well_known!` for types from
44// RFC 1035, `dname_type_canonical!` for non-RFC 1035 types that need to be
45// lowercased, and `dname_type!` for everything else.
46
47#[macro_use]
48mod macros;
49
50// The rdata_types! macro (defined in self::macros) defines the modules
51// containing the record data types, re-exports those here, and creates the
52// ZoneRecordData and AllRecordData enums containing all record types that
53// can appear in a zone file and all record types that exist.
54//
55// All record data types listed here MUST have the same name as the
56// `Rtype` variant they implement – some of the code implemented by the macro
57// relies on that.
58//
59// Add any new module here and then add all record types in that module that
60// can appear in zone files under "zone" and all others under "pseudo".
61// Your type can be generic over an octet type "O" and a domain name type "N".
62// Add these as needed. Trait bounds on them differ for different methods, so
63// check the bounds on ZoneRecordData and AllRecordData if there are errors.
64rdata_types! {
65 rfc1035::{
66 zone {
67 A,
68 Cname<N>,
69 Hinfo<O>,
70 Mb<N>,
71 Md<N>,
72 Mf<N>,
73 Mg<N>,
74 Minfo<N>,
75 Mr<N>,
76 Mx<N>,
77 Ns<N>,
78 Ptr<N>,
79 Soa<N>,
80 Txt<O>,
81 }
82 pseudo {
83 Null<O>
84 }
85 }
86 aaaa::{
87 zone {
88 Aaaa,
89 }
90 }
91 cds::{
92 zone {
93 Cdnskey<O>,
94 Cds<O>,
95 }
96 }
97 dname::{
98 zone {
99 Dname<N>,
100 }
101 }
102 dnssec::{
103 zone {
104 Dnskey<O>,
105 Rrsig<O, N>,
106 Nsec<O, N>,
107 Ds<O>,
108 }
109 }
110 nsec3::{
111 zone {
112 Nsec3<O>,
113 Nsec3param<O>,
114 }
115 }
116 srv::{
117 zone {
118 Srv<N>,
119 }
120 }
121 svcb::{
122 pseudo {
123 Svcb<O, N>,
124 Https<O, N>,
125 }
126 }
127 tsig::{
128 pseudo {
129 Tsig<O, N>,
130 }
131 }
132 zonemd::{
133 zone {
134 Zonemd<O>,
135 }
136 }
137}