1use core::fmt::{Debug, Display};
11
12use crate::serialize::binary::{BinDecodable, BinDecoder, BinEncodable, DecodeError, Restrict};
13
14pub(crate) mod dns_class;
15pub use dns_class::DNSClass;
16
17pub mod domain;
18pub use domain::{IntoName, Label, Name};
19
20mod lower_name;
21pub use lower_name::LowerName;
22
23pub mod rdata;
24
25pub(crate) mod record;
26pub use record::{Record, RecordRef};
27
28pub(crate) mod record_data;
29pub use record_data::RData;
30
31pub(crate) mod record_type;
32pub use record_type::RecordType;
33
34pub(crate) mod record_type_set;
35pub use record_type_set::RecordTypeSet;
36
37mod rr_key;
38pub use rr_key::RrKey;
39
40mod rr_set;
41#[cfg(feature = "__dnssec")]
42pub use rr_set::RecordsAndRrsigsIter;
43pub use rr_set::{RecordSet, RecordSetParts, RrsetRecords};
44
45pub(crate) mod serial_number;
46pub use serial_number::SerialNumber;
47
48mod tsig;
49#[cfg(feature = "__dnssec")]
50pub use tsig::TSigVerifier;
51pub use tsig::{TSigResponseContext, TSigner};
52
53pub trait RecordData: Clone + Sized + PartialEq + Eq + Display + Debug + BinEncodable {
57 fn try_borrow(data: &RData) -> Option<&Self>;
59
60 fn record_type(&self) -> RecordType;
62
63 fn into_rdata(self) -> RData;
65
66 fn is_update(&self) -> bool {
68 false
69 }
70}
71
72pub(crate) trait RecordDataDecodable<'r>: Sized {
73 fn read_data(decoder: &mut BinDecoder<'r>, length: Restrict<u16>) -> Result<Self, DecodeError>;
79}
80
81impl<'r, T> RecordDataDecodable<'r> for T
82where
83 T: 'r + BinDecodable<'r> + Sized,
84{
85 fn read_data(
86 decoder: &mut BinDecoder<'r>,
87 _length: Restrict<u16>,
88 ) -> Result<Self, DecodeError> {
89 T::read(decoder)
90 }
91}