+#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
+/// A Delegation Name resource record, referring all queries for subdomains of this name to another
+/// subtree of the DNS.
+pub struct DName {
+ /// The name this record is at.
+ pub name: Name,
+ /// The delegation name.
+ ///
+ /// A resolver should use this domain name tree when looking up any further records for
+ /// subdomains of [`self.name`].
+ pub delegation_name: Name,
+}
+impl StaticRecord for DName {
+ const TYPE: u16 = 39;
+ fn name(&self) -> &Name { &self.name }
+ fn json(&self) -> String {
+ format!("{{\"type\":\"dname\",\"name\":\"{}\",\"delegation_name\":\"{}\"}}",
+ self.name.0, self.delegation_name.0)
+ }
+ fn read_from_data(name: Name, mut data: &[u8], wire_packet: &[u8]) -> Result<Self, ()> {
+ Ok(DName { name, delegation_name: read_wire_packet_name(&mut data, wire_packet)? })
+ }
+ fn write_u16_len_prefixed_data(&self, out: &mut Vec<u8>) {
+ let len: u16 = name_len(&self.delegation_name);
+ out.extend_from_slice(&len.to_be_bytes());
+ write_name(out, &self.delegation_name);
+ }
+}
+
+