1 use super::*; 2 use crate::error::Result; 3 use crate::message::name::*; 4 5 // A PTRResource is a PTR Resource record. 6 #[derive(Default, Debug, Clone, PartialEq, Eq)] 7 pub struct PtrResource { 8 pub ptr: Name, 9 } 10 11 impl fmt::Display for PtrResource { 12 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 13 write!(f, "dnsmessage.PTRResource{{PTR: {}}}", self.ptr) 14 } 15 } 16 17 impl ResourceBody for PtrResource { 18 fn real_type(&self) -> DnsType { 19 DnsType::Ptr 20 } 21 22 // pack appends the wire format of the PTRResource to msg. 23 fn pack( 24 &self, 25 msg: Vec<u8>, 26 compression: &mut Option<HashMap<String, usize>>, 27 compression_off: usize, 28 ) -> Result<Vec<u8>> { 29 self.ptr.pack(msg, compression, compression_off) 30 } 31 32 fn unpack(&mut self, msg: &[u8], off: usize, _length: usize) -> Result<usize> { 33 self.ptr.unpack(msg, off) 34 } 35 } 36