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
//! A DNS library for Rust.
//!
//! This crate provides a number of building blocks for developing
//! functionality related to the [Domain Name System (DNS)][dns].
//!
//! [dns]: https://www.rfc-editor.org/rfc/rfc9499.html
//!
//! The crate uses feature flags to allow you to select only those modules
//! you need for your particular project. In most cases, the feature names
//! are equal to the module they enable.
//!
//! # Modules
//!
//! A set of modules providing fundamental types and functionality is always
//! enabled:
//!
//! * [base] contains a wide variety of types, traits, and functionality
//! to deal with DNS data, and
//! * [rdata] contains types and implementations for a growing number of
//! record types.
//!
//! The following additional modules exist, although they are gated behind
//! feature flags (with the same names as the modules):
//!
//! Sending and receiving DNS messages.
//! An asynchronous DNS resolver based on the
//! [Tokio](https://tokio.rs/) async runtime.
//! Experimental support for cryptographic backends, key generation and
//! import. Gated behind the `unstable-crypto` flag.
//! * [dnssec]: DNSSEC signing and validation.
//! Support for securing DNS transactions with TSIG records.
//! Experimental reading and writing of zone files, i.e. the textual
//! representation of DNS data.
//! Experimental storing and querying of zone trees. Gated behind the
//! `unstable-zonetree` flag.
//!
//! Finally, the [dep] module contains re-exports of some important
//! dependencies to help avoid issues with multiple versions of a crate.
//!
//! # The `new` Module
//!
//! The API of `domain` is undergoing several large-scale changes, that are
//! collected under the `new` module. It is gated behind the `unstable-new`
//! flag.
//!
//! # Reference of feature flags
//!
//! Several feature flags simply enable support for other crates, e.g. by
//! adding `impl`s for their types. They are optional and do not introduce
//! new functionality into this crate.
//!
//! * `bytes`: Enables using the types `Bytes` and `BytesMut` from the
//! [bytes](https://github.com/tokio-rs/bytes) crate as octet sequences.
//!
//! * `heapless`: enables the use of the `Vec` type from the
//! [heapless](https://github.com/japaric/heapless) crate as octet
//! sequences.
//!
//! * `smallvec`: enables the use of the `Smallvec` type from the
//! [smallvec](https://github.com/servo/rust-smallvec) crate as octet
//! sequences.
//!
//! Some flags enable support for specific kinds of operations that are not
//! otherwise possible. They are gated as they may not always be necessary
//! and they may introduce new dependencies.
//!
//! * `chrono`: Adds the [chrono](https://github.com/chronotope/chrono)
//! crate as a dependency. This adds support for generating serial numbers
//! from time stamps.
//!
//! * `rand`: Enables a number of methods that rely on a random number
//! generator being available in the system.
//!
//! * `serde`: Enables serde serialization for a number of basic types.
//!
//! * `siphasher`: enables the dependency on the
//! [siphasher](https://github.com/jedisct1/rust-siphash) crate which allows
//! generating and checking hashes in [standard server
//! cookies][crate::base::opt::cookie::StandardServerCookie].
//!
//! * `std`: support for the Rust std library. This feature is enabled by
//! default.
//!
//! A special case here is cryptographic backends. Certain modules (e.g. for
//! DNSSEC signing and validation) require a backend to provide cryptography.
//! At least one such module should be enabled.
//!
//! * `openssl`: Enables crypto functionality via OpenSSL through the
//! [rust-openssl](https://github.com/sfackler/rust-openssl) crate.
//!
//! * `ring`: Enables crypto functionality via the
//! [ring](https://github.com/briansmith/ring) crate.
//!
//! Some flags represent entire categories of functionality within this crate.
//! Each flag is associated with a particular module. Note that some of these
//! modules are under heavy development, and so have unstable feature flags
//! which are categorized separately.
//!
//! * `net`: Enables sending and receiving DNS messages via the
//! module.
//!
//! * `resolv`: Enables the asynchronous stub resolver via the
//! module.
//!
//! * `resolv-sync`: Enables the synchronous version of the stub resolver.
//!
//! * `tsig`: support for signing and validating message exchanges via TSIG
//! signatures. This enables the
//! module and currently enables `bytes`, `ring`, and `smallvec`.
//!
//! * `zonefile`: reading and writing of zonefiles. This feature enables the
//! module and currently also enables `bytes`, `serde`, and `std`.
//!
//! # Unstable features
//!
//! When adding new functionality to the crate, practical experience is
//! necessary to arrive at a good, user friendly design. Unstable features
//! allow adding and rapidly changing new code without having to release
//! versions allowing breaking changes all the time. If you use unstable
//! features, it is best to specify a concrete version as a dependency in
//! `Cargo.toml` using the `=` operator, e.g.:
//!
//! ```text
//! [dependencies]
//! domain = "=0.9.3"
//! ```
//!
//! Currently, the following unstable features exist:
//!
//! * `unstable-client-transport`: sending and receiving DNS messages from
//! a client perspective; primarily the `net::client` module.
//! * `unstable-server-transport`: receiving and sending DNS messages from
//! a server perspective; primarily the `net::server` module.
//! * `unstable-crypto`: this feature flag needs to be combined with one or
//! more feature flags that enable cryptographic backends (currently `ring`
//! and `openssl`). This feature flags enables all parts of the crypto
//! module except for private key generation and signing.
//! * `unstable-crypto-sign`: this feature flag needs to be combined with one
//! or more feature flags that enable cryptographic backends. This feature
//! flag enables all parts of the crypto module.
//! * `unstable-sign`: basic DNSSEC signing support. This will enable the
//! `dnssec::sign`
//! module and requires the `std` feature. In order to actually perform any
//! signing, also enable one or more cryptographic backend modules (`ring`
//! and `openssl`). Enabling this will also enable `unstable-crypto-sign`.
//! * `unstable-validator`: a DNSSEC validator, primarily the `validator`
//! and the `net::client::validator` modules.
//! * `unstable-xfr`: zone transfer related functionality..
//! * `unstable-zonetree`: building & querying zone trees; primarily the
//! `zonetree` module.
//!
//! Note: Some functionality is currently informally marked as
//! “experimental” since it was introduced before adoption of the concept
//! of unstable features. These will follow proper Semver practice but may
//! change significantly in releases with breaking changes.
extern crate alloc;
// Import macros even if unused.
extern crate std;
// The 'domain-macros' crate introduces 'derive' macros which can be used by
// users of the 'domain' crate, but also by the 'domain' crate itself. Within
// those macros, references to declarations in the 'domain' crate are written
// as '::domain::*' ... but this doesn't work when those proc macros are used
// in the 'domain' crate itself. The alias introduced here fixes this: now
// '::domain' means the same thing within this crate as in dependents of it.
extern crate self as domain;
// Re-export 'core' for use in macros.
pub use core as __core;