domain/base/iana/class.rs
1//! DNS CLASSes.
2
3//------------ Class ---------------------------------------------------------
4
5int_enum! {
6 /// DNS CLASSes.
7 ///
8 /// The domain name space is partitioned into separate classes for different
9 /// network types. That is, each class has its own separate record tree
10 /// starting at the root. However, in practice, only the IN class is really
11 /// relevant.
12 ///
13 /// In addition, there are query classes or QCLASSes that are used in
14 /// questions or UPDATE queries, namely NONE and ANY (or *).
15 ///
16 /// Classes are represented by a 16 bit value. The enum wraps these values.
17 ///
18 /// See [RFC 1034] for the introduction of classes, section 3.2 of
19 /// [RFC 6895] for a discussion of the current state of afairs, and
20 /// the [DNS CLASSes IANA registry] for an overview of assigned values.
21 /// This type is complete as of the registry update of 2019-01-28.
22 ///
23 /// [RFC 1034]: https://tools.ietf.org/html/rfc1034
24 /// [RFC 6895]: https://tools.ietf.org/html/rfc6895
25 /// [DNS CLASSes IANA registry]: http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-2
26 =>
27 Class, u16;
28
29 /// Internet (IN).
30 ///
31 /// This class is defined in RFC 1035 and really the only one relevant
32 /// at all.
33 (In => 1, b"IN")
34
35 /// Chaosnet (CH).
36 ///
37 /// A network protocol developed at MIT in the 1970s. Reused by BIND for
38 /// built-in server information zones.",
39 (Ch => 3, b"CH")
40
41 /// Hesiod (HS).
42 ///
43 /// A system information protocol part of MIT's Project Athena.",
44 (Hs => 4, b"HS")
45
46 /// Query class None.
47 ///
48 /// Defined in RFC 2136, this class is used in UPDATE queries to
49 /// require that an RRset does not exist prior to the update.",
50 (None => 0xFE, b"NONE")
51
52 /// Query class * (ANY).
53 ///
54 /// This class can be used in a query to indicate that records for the
55 /// given name from any class are requested.",
56 (Any => 0xFF, b"*")
57}
58
59int_enum_str_with_prefix!(Class, "CLASS", b"CLASS", u16, "unknown class");
60
61//============ Tests =========================================================
62
63#[cfg(test)]
64mod test {
65 #[cfg(feature = "serde")]
66 #[test]
67 fn ser_de() {
68 use super::Class;
69 use serde_test::{assert_tokens, Configure, Token};
70
71 assert_tokens(&Class::In.readable(), &[Token::Str("IN")]);
72 assert_tokens(&Class::Int(5).readable(), &[Token::Str("CLASS5")]);
73 assert_tokens(&Class::In.compact(), &[Token::U16(1)]);
74 assert_tokens(&Class::Int(5).compact(), &[Token::U16(5)]);
75 }
76}