1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
use std::fmt::Display;

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// Domain Name System type.
#[allow(clippy::upper_case_acronyms)]
#[derive(
    Default,
    Serialize,
    Deserialize,
    JsonSchema,
    Clone,
    Copy,
    Debug,
    Hash,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
)]
pub enum Type {
    /// Address record
    ///
    /// Returns a 32-bit IPv4 address, most commonly used to map hostnames to an IP address of the host, but it is also used for DNSBLs, storing subnet masks in RFC 1101, etc.
    ///
    /// [1035](https://datatracker.ietf.org/doc/html/rfc1035)
    #[default]
    A,
    /// IPv6 address record
    ///
    /// Returns a 128-bit IPv6 address, most commonly used to map hostnames to an IP address of the host.
    ///
    /// [3596](https://datatracker.ietf.org/doc/html/rfc3596)
    AAAA,
    /// AFS database record
    ///
    /// Location of database servers of an AFS cell. This record is commonly used by AFS clients to contact AFS cells outside their local domain. A subtype of this record is used by the obsolete DCE/DFS file system.
    ///
    /// [1183](https://datatracker.ietf.org/doc/html/rfc1183)
    AFSDB,
    /// Address Prefix List
    ///
    /// Specify lists of address ranges, e.g. in CIDR format, for various address families. Experimental.
    ///
    /// [3123](https://datatracker.ietf.org/doc/html/rfc3123)
    APL,
    /// Certification Authority Authorization
    ///
    /// DNS Certification Authority Authorization, constraining acceptable CAs for a host/domain
    ///
    /// [6844](https://datatracker.ietf.org/doc/html/rfc6844)
    CAA,
    /// Child copy of DNSKEY record, for transfer to parent
    ///
    /// [7344](https://datatracker.ietf.org/doc/html/rfc7344)
    CDNSKEY,
    /// Child DS
    ///
    /// Child copy of DS record, for transfer to parent
    ///
    /// [7344](https://datatracker.ietf.org/doc/html/rfc7344)
    CDS,
    /// Certificate record
    ///
    /// Stores PKIX, SPKI, PGP, etc.
    ///
    /// [4398](https://datatracker.ietf.org/doc/html/rfc4398)
    CERT,
    /// Canonical name record
    ///
    /// Alias of one name to another: the DNS lookup will continue by retrying the lookup with the new name.
    ///
    /// [1035](https://datatracker.ietf.org/doc/html/rfc1035)
    CNAME,
    /// Child-to-Parent Synchronization
    ///
    /// Specify a synchronization mechanism between a child and a parent DNS zone. Typical example is declaring the same NS records in the parent and the child zone
    ///
    /// [7477](https://datatracker.ietf.org/doc/html/rfc7477)
    CSYNC,
    /// DHCP identifier
    ///
    /// Used in conjunction with the FQDN option to DHCP
    ///
    /// [4701](https://datatracker.ietf.org/doc/html/rfc4701)
    DHCID,
    /// DNSSEC Lookaside Validation record
    ///
    /// For publishing DNSSEC trust anchors outside of the DNS delegation chain. Uses the same format as the DS record. RFC 5074 describes a way of using these records.
    ///
    /// [4431](https://datatracker.ietf.org/doc/html/rfc4431)
    DLV,
    /// Delegation name record
    ///
    /// Alias for a name and all its subnames, unlike CNAME, which is an alias for only the exact name. Like a CNAME record, the DNS lookup will continue by retrying the lookup with the new name.
    ///
    /// [6672](https://datatracker.ietf.org/doc/html/rfc6672)
    DNAME,
    /// DNS Key record
    ///
    /// The key record used in DNSSEC. Uses the same format as the KEY record.
    ///
    /// [4034](https://datatracker.ietf.org/doc/html/rfc4034)
    DNSKEY,
    /// Delegation signer
    ///
    /// The record used to identify the DNSSEC signing key of a delegated zone
    ///
    /// [4034](https://datatracker.ietf.org/doc/html/rfc4034)
    DS,
    /// MAC address (EUI-48)
    ///
    /// A 48-bit IEEE Extended Unique Identifier.
    ///
    /// [7043](https://datatracker.ietf.org/doc/html/rfc7043)
    EUI48,
    /// MAC address (EUI-64)
    ///
    /// A 64-bit IEEE Extended Unique Identifier.
    ///
    /// [7043](https://datatracker.ietf.org/doc/html/rfc7043)
    EUI64,
    /// Host Information
    ///
    /// Providing Minimal-Sized Responses to DNS Queries That Have QTYPE=ANY
    ///
    /// [8482](https://datatracker.ietf.org/doc/html/rfc8482)
    HINFO,
    /// Host Identity Protocol
    ///
    /// Method of separating the end-point identifier and locator roles of IP addresses.
    ///
    /// [8005](https://datatracker.ietf.org/doc/html/rfc8005)
    HIP,
    /// HTTPS Binding
    ///
    /// RR that improves performance for clients that need to resolve many resources to access a domain.
    ///
    /// [9460](https://datatracker.ietf.org/doc/html/rfc9460)
    HTTPS,
    /// IPsec Key
    ///
    /// Key record that can be used with IPsec
    ///
    /// [4025](https://datatracker.ietf.org/doc/html/rfc4025)
    IPSECKEY,
    /// Key record
    ///
    /// Used only for SIG(0) (RFC 2931) and TKEY (RFC 2930).[5] RFC 3445 eliminated their use for application keys and limited their use to DNSSEC.[6] RFC 3755 designates DNSKEY as the replacement within DNSSEC.[7] RFC 4025 designates IPSECKEY as the replacement for use with IPsec.[8]
    ///
    /// [2535](https://datatracker.ietf.org/doc/html/rfc2535)
    /// [2930](https://datatracker.ietf.org/doc/html/rfc2930)
    KEY,
    /// Key Exchanger record
    ///
    /// Used with some cryptographic systems (not including DNSSEC) to identify a key management agent for the associated domain-name. Note that this has nothing to do with DNS Security. It is Informational status, rather than being on the IETF standards-track. It has always had limited deployment, but is still in use.
    ///
    /// [2230](https://datatracker.ietf.org/doc/html/rfc2230)
    KX,
    /// Location record
    ///
    /// Specifies a geographical location associated with a domain name
    ///
    /// [1876](https://datatracker.ietf.org/doc/html/rfc1876)
    LOC,
    /// Mail exchange record
    ///
    /// List of mail exchange servers that accept email for a domain
    ///
    /// [1035](https://datatracker.ietf.org/doc/html/rfc1035)
    /// [7505](https://datatracker.ietf.org/doc/html/rfc7505)
    MX,
    /// Naming Authority Pointer
    ///
    /// Allows regular-expression-based rewriting of domain names which can then be used as URIs, further domain names to lookups, etc.
    ///
    /// [3403](https://datatracker.ietf.org/doc/html/rfc3403)
    NAPTR,
    /// Name server record
    ///
    /// Delegates a DNS zone to use the given authoritative name servers
    ///
    /// [1035](https://datatracker.ietf.org/doc/html/rfc1035)
    NS,
    /// Next Secure record
    ///
    /// Part of DNSSEC—used to prove a name does not exist. Uses the same format as the (obsolete) NXT record.
    ///
    /// [4034](https://datatracker.ietf.org/doc/html/rfc4034)
    NSEC,
    /// Next Secure record version 3
    ///
    /// An extension to DNSSEC that allows proof of nonexistence for a name without permitting zonewalking
    ///
    /// [5155](https://datatracker.ietf.org/doc/html/rfc5155)
    NSEC3,
    /// NSEC3 parameters
    ///
    /// Parameter record for use with NSEC3
    ///
    /// [5155](https://datatracker.ietf.org/doc/html/rfc5155)
    NSEC3PARAM,
    /// OpenPGP public key record
    ///
    /// A DNS-based Authentication of Named Entities (DANE) method for publishing and locating OpenPGP public keys in DNS for a specific email address using an OPENPGPKEY DNS resource record.
    ///
    /// [7929](https://datatracker.ietf.org/doc/html/rfc7929)
    OPENPGPKEY,
    /// PTR Resource Record
    ///
    /// Pointer to a canonical name. Unlike a CNAME, DNS processing stops and just the name is returned. The most common use is for implementing reverse DNS lookups, but other uses include such things as DNS-SD.
    ///
    /// [1035](https://datatracker.ietf.org/doc/html/rfc1035)
    PTR,
    /// DNSSEC signature
    ///
    /// Signature for a DNSSEC-secured record set. Uses the same format as the SIG record.
    ///
    /// [4034](https://datatracker.ietf.org/doc/html/rfc4034)
    RRSIG,
    /// Responsible Person
    ///
    /// Information about the responsible person(s) for the domain. Usually an email address with the @ replaced by a .
    ///
    /// [1183](https://datatracker.ietf.org/doc/html/rfc1183)
    RP,
    /// Signature
    ///
    /// Signature record used in SIG(0) (RFC 2931) and TKEY (RFC 2930).[7] RFC 3755 designated RRSIG as the replacement for SIG for use within DNSSEC.[7]
    ///
    /// [2535](https://datatracker.ietf.org/doc/html/rfc2535)
    SIG,
    /// S/MIME cert association
    ///
    /// Associates an S/MIME certificate with a domain name for sender authentication.
    ///
    /// [8162](https://datatracker.ietf.org/doc/html/rfc8162)
    SMIMEA,
    /// Start of [a zone of] authority record
    ///
    /// Specifies authoritative information about a DNS zone, including the primary name server, the email of the domain administrator, the domain serial number, and several timers relating to refreshing the zone.
    ///
    /// [1035](https://datatracker.ietf.org/doc/html/rfc1035)
    /// [2308](https://datatracker.ietf.org/doc/html/rfc2308)
    SOA,
    /// Service locator
    ///
    /// Generalized service location record, used for newer protocols instead of creating protocol-specific records such as MX.
    ///
    /// [2782](https://datatracker.ietf.org/doc/html/rfc2782)
    SRV,
    /// SSH Public Key Fingerprint
    ///
    /// Resource record for publishing SSH public host key fingerprints in the DNS, in order to aid in verifying the authenticity of the host. RFC 6594 defines ECC SSH keys and SHA-256 hashes. See the IANA SSHFP RR parameters registry for details.
    ///
    /// [4255](https://datatracker.ietf.org/doc/html/rfc4255)
    SSHFP,
    /// Service Binding
    ///
    /// RR that improves performance for clients that need to resolve many resources to access a domain.
    ///
    /// [9460](https://datatracker.ietf.org/doc/html/rfc9460)
    SVCB,
    /// DNSSEC Trust Authorities
    ///
    /// Part of a deployment proposal for DNSSEC without a signed DNS root. See the IANA database and Weiler Spec for details. Uses the same format as the DS record.
    TA,
    /// Transaction Key record
    ///
    /// A method of providing keying material to be used with TSIG that is encrypted under the public key in an accompanying KEY RR.[12]
    ///
    /// [2930](https://datatracker.ietf.org/doc/html/rfc2930)
    TKEY,
    /// TLSA certificate association
    ///
    /// A record for DANE. RFC 6698 defines "The TLSA DNS resource record is used to associate a TLS server certificate or public key with the domain name where the record is found, thus forming a 'TLSA certificate association'".
    ///
    /// [6698](https://datatracker.ietf.org/doc/html/rfc6698)
    TLSA,
    /// Transaction Signature
    ///
    /// Can be used to authenticate dynamic updates as coming from an approved client, or to authenticate responses as coming from an approved recursive name server[13] similar to DNSSEC.
    ///
    /// [2845](https://datatracker.ietf.org/doc/html/rfc2845)
    TSIG,
    /// Text record
    ///
    /// Originally for arbitrary human-readable text in a DNS record. Since the early 1990s, however, this record more often carries machine-readable data, such as specified by RFC 1464, opportunistic encryption, Sender Policy Framework, DKIM, DMARC, DNS-SD, etc.
    ///
    /// [1035](https://datatracker.ietf.org/doc/html/rfc1035)
    TXT,
    /// Uniform Resource Identifier
    ///
    /// Can be used for publishing mappings from hostnames to URIs.
    ///
    /// [7553](https://datatracker.ietf.org/doc/html/rfc7553)
    URI,
    /// Message Digests for DNS Zones
    ///
    /// Provides a cryptographic message digest over DNS zone data at rest.
    ///
    /// [8976](https://datatracker.ietf.org/doc/html/rfc8976)
    ZONEMD,
}

impl Type {
    pub fn is_a(&self) -> bool {
        *self == Self::A
    }
    pub fn is_aaaa(&self) -> bool {
        *self == Self::AAAA
    }
    pub fn is_afsdb(&self) -> bool {
        *self == Self::AFSDB
    }
    pub fn is_apl(&self) -> bool {
        *self == Self::APL
    }
    pub fn is_caa(&self) -> bool {
        *self == Self::CAA
    }
    pub fn is_cdnskey(&self) -> bool {
        *self == Self::CDNSKEY
    }
    pub fn is_cds(&self) -> bool {
        *self == Self::CDS
    }
    pub fn is_cert(&self) -> bool {
        *self == Self::CERT
    }
    pub fn is_cname(&self) -> bool {
        *self == Self::CNAME
    }
    pub fn is_csync(&self) -> bool {
        *self == Self::CSYNC
    }
    pub fn is_dhcid(&self) -> bool {
        *self == Self::DHCID
    }
    pub fn is_dlv(&self) -> bool {
        *self == Self::DLV
    }
    pub fn is_dname(&self) -> bool {
        *self == Self::DNAME
    }
    pub fn is_dnskey(&self) -> bool {
        *self == Self::DNSKEY
    }
    pub fn is_ds(&self) -> bool {
        *self == Self::DS
    }
    pub fn is_eui48(&self) -> bool {
        *self == Self::EUI48
    }
    pub fn is_eui64(&self) -> bool {
        *self == Self::EUI64
    }
    pub fn is_hinfo(&self) -> bool {
        *self == Self::HINFO
    }
    pub fn is_hip(&self) -> bool {
        *self == Self::HIP
    }
    pub fn is_https(&self) -> bool {
        *self == Self::HTTPS
    }
    pub fn is_ipseckey(&self) -> bool {
        *self == Self::IPSECKEY
    }
    pub fn is_key(&self) -> bool {
        *self == Self::KEY
    }
    pub fn is_kx(&self) -> bool {
        *self == Self::KX
    }
    pub fn is_loc(&self) -> bool {
        *self == Self::LOC
    }
    pub fn is_mx(&self) -> bool {
        *self == Self::MX
    }
    pub fn is_naptr(&self) -> bool {
        *self == Self::NAPTR
    }
    pub fn is_ns(&self) -> bool {
        *self == Self::NS
    }
    pub fn is_nsec(&self) -> bool {
        *self == Self::NSEC
    }
    pub fn is_nsec3(&self) -> bool {
        *self == Self::NSEC3
    }
    pub fn is_nsec3param(&self) -> bool {
        *self == Self::NSEC3PARAM
    }
    pub fn is_openpgpkey(&self) -> bool {
        *self == Self::OPENPGPKEY
    }
    pub fn is_ptr(&self) -> bool {
        *self == Self::PTR
    }
    pub fn is_rrsig(&self) -> bool {
        *self == Self::RRSIG
    }
    pub fn is_rp(&self) -> bool {
        *self == Self::RP
    }
    pub fn is_sig(&self) -> bool {
        *self == Self::SIG
    }
    pub fn is_smimea(&self) -> bool {
        *self == Self::SMIMEA
    }
    pub fn is_soa(&self) -> bool {
        *self == Self::SOA
    }
    pub fn is_srv(&self) -> bool {
        *self == Self::SRV
    }
    pub fn is_sshfp(&self) -> bool {
        *self == Self::SSHFP
    }
    pub fn is_svcb(&self) -> bool {
        *self == Self::SVCB
    }
    pub fn is_ta(&self) -> bool {
        *self == Self::TA
    }
    pub fn is_tkey(&self) -> bool {
        *self == Self::TKEY
    }
    pub fn is_tlsa(&self) -> bool {
        *self == Self::TLSA
    }
    pub fn is_tsig(&self) -> bool {
        *self == Self::TSIG
    }
    pub fn is_txt(&self) -> bool {
        *self == Self::TXT
    }
    pub fn is_uri(&self) -> bool {
        *self == Self::URI
    }
    pub fn is_zonemd(&self) -> bool {
        *self == Self::ZONEMD
    }
}

impl Display for Type {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::A => f.write_str("A"),
            Self::AAAA => f.write_str("AAAA"),
            Self::AFSDB => f.write_str("AFSDB"),
            Self::APL => f.write_str("APL"),
            Self::CAA => f.write_str("CAA"),
            Self::CDNSKEY => f.write_str("CDNSKEY"),
            Self::CDS => f.write_str("CDS"),
            Self::CERT => f.write_str("CERT"),
            Self::CNAME => f.write_str("CNAME"),
            Self::CSYNC => f.write_str("CSYNC"),
            Self::DHCID => f.write_str("DHCID"),
            Self::DLV => f.write_str("DLV"),
            Self::DNAME => f.write_str("DNAME"),
            Self::DNSKEY => f.write_str("DNSKEY"),
            Self::DS => f.write_str("DS"),
            Self::EUI48 => f.write_str("EUI48"),
            Self::EUI64 => f.write_str("EUI64"),
            Self::HINFO => f.write_str("HINFO"),
            Self::HIP => f.write_str("HIP"),
            Self::HTTPS => f.write_str("HTTPS"),
            Self::IPSECKEY => f.write_str("IPSECKEY"),
            Self::KEY => f.write_str("KEY"),
            Self::KX => f.write_str("KX"),
            Self::LOC => f.write_str("LOC"),
            Self::MX => f.write_str("MX"),
            Self::NAPTR => f.write_str("NAPTR"),
            Self::NS => f.write_str("NS"),
            Self::NSEC => f.write_str("NSEC"),
            Self::NSEC3 => f.write_str("NSEC3"),
            Self::NSEC3PARAM => f.write_str("NSEC3PARAM"),
            Self::OPENPGPKEY => f.write_str("OPENPGPKEY"),
            Self::PTR => f.write_str("PTR"),
            Self::RRSIG => f.write_str("RRSIG"),
            Self::RP => f.write_str("RP"),
            Self::SIG => f.write_str("SIG"),
            Self::SMIMEA => f.write_str("SMIMEA"),
            Self::SOA => f.write_str("SOA"),
            Self::SRV => f.write_str("SRV"),
            Self::SSHFP => f.write_str("SSHFP"),
            Self::SVCB => f.write_str("SVCB"),
            Self::TA => f.write_str("TA"),
            Self::TKEY => f.write_str("TKEY"),
            Self::TLSA => f.write_str("TLSA"),
            Self::TSIG => f.write_str("TSIG"),
            Self::TXT => f.write_str("TXT"),
            Self::URI => f.write_str("URI"),
            Self::ZONEMD => f.write_str("ZONEMD"),
        }
    }
}