xref: /webrtc/mdns/src/message/resource/ns.rs (revision ffe74184)
1 use super::*;
2 use crate::error::Result;
3 use crate::message::name::*;
4 
5 // An NSResource is an NS Resource record.
6 #[derive(Default, Debug, Clone, PartialEq, Eq)]
7 pub struct NsResource {
8     pub ns: Name,
9 }
10 
11 impl fmt::Display for NsResource {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result12     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13         write!(f, "dnsmessage.NSResource{{NS: {}}}", self.ns)
14     }
15 }
16 
17 impl ResourceBody for NsResource {
real_type(&self) -> DnsType18     fn real_type(&self) -> DnsType {
19         DnsType::Ns
20     }
21 
22     // pack appends the wire format of the NSResource to msg.
pack( &self, msg: Vec<u8>, compression: &mut Option<HashMap<String, usize>>, compression_off: usize, ) -> Result<Vec<u8>>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.ns.pack(msg, compression, compression_off)
30     }
31 
unpack(&mut self, msg: &[u8], off: usize, _txt_length: usize) -> Result<usize>32     fn unpack(&mut self, msg: &[u8], off: usize, _txt_length: usize) -> Result<usize> {
33         self.ns.unpack(msg, off)
34     }
35 }
36