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
48// The rdata_types! macro (defined in self::macros) defines the modules
49// containing the record data types, re-exports those here, and creates the
50// ZoneRecordData and AllRecordData enums containing all record types that
51// can appear in a zone file and all record types that exist.
52//
53// All record data types listed here MUST have the same name as the
54// `Rtype` variant they implement – some of the code implemented by the macro
55// relies on that.
56//
57// Add any new module here and then add all record types in that module that
58// can appear in zone files under "zone" and all others under "pseudo".
59// Your type can be generic over an octet type "O" and a domain name type "N".
60// Add these as needed. Trait bounds on them differ for different methods, so
61// check the bounds on ZoneRecordData and AllRecordData if there are errors.
62rdata_types! {
63 rfc1035::{
64 zone {
65 A,
66 Cname<N>,
67 Hinfo<O>,
68 Mb<N>,
69 Md<N>,
70 Mf<N>,
71 Mg<N>,
72 Minfo<N>,
73 Mr<N>,
74 Mx<N>,
75 Ns<N>,
76 Ptr<N>,
77 Soa<N>,
78 Txt<O>,
79 }
80 pseudo {
81 Null<O>
82 }
83 }
84 aaaa::{
85 zone {
86 Aaaa,
87 }
88 }
89 cds::{
90 zone {
91 Cdnskey<O>,
92 Cds<O>,
93 }
94 }
95 dname::{
96 zone {
97 Dname<N>,
98 }
99 }
100 dnssec::{
101 zone {
102 Dnskey<O>,
103 Rrsig<O, N>,
104 Nsec<O, N>,
105 Ds<O>,
106 }
107 }
108 naptr::{
109 zone {
110 Naptr<O, N>,
111 }
112 }
113 nsec3::{
114 zone {
115 Nsec3<O>,
116 Nsec3param<O>,
117 }
118 }
119 srv::{
120 zone {
121 Srv<N>,
122 }
123 }
124 svcb::{
125 pseudo {
126 Svcb<O, N>,
127 Https<O, N>,
128 }
129 }
130 tsig::{
131 pseudo {
132 Tsig<O, N>,
133 }
134 }
135 zonemd::{
136 zone {
137 Zonemd<O>,
138 }
139 }
140}