webrtc_mdns/message/resource/
aaaa.rs

1use super::*;
2use crate::message::packer::*;
3
4// An AAAAResource is an aaaa Resource record.
5#[derive(Default, Debug, Clone, PartialEq, Eq)]
6pub struct AaaaResource {
7    pub aaaa: [u8; 16],
8}
9
10impl fmt::Display for AaaaResource {
11    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12        write!(f, "dnsmessage.AAAAResource{{aaaa: {:?}}}", self.aaaa)
13    }
14}
15
16impl ResourceBody for AaaaResource {
17    fn real_type(&self) -> DnsType {
18        DnsType::Aaaa
19    }
20
21    // pack appends the wire format of the AAAAResource to msg.
22    fn pack(
23        &self,
24        msg: Vec<u8>,
25        _compression: &mut Option<HashMap<String, usize>>,
26        _compression_off: usize,
27    ) -> Result<Vec<u8>> {
28        Ok(pack_bytes(msg, &self.aaaa))
29    }
30
31    fn unpack(&mut self, msg: &[u8], off: usize, _length: usize) -> Result<usize> {
32        unpack_bytes(msg, off, &mut self.aaaa)
33    }
34}