1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::fmt::{Debug, Formatter};
use crate::message::record::RData;
use crate::string::encode_domain_name;

pub struct CnameRdata {
    pub rdata: String
}

impl Debug for CnameRdata {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("CNAME")
            .field("Host", &self.rdata)
            .finish()
    }
}

impl RData for CnameRdata {
    fn to_bytes(&self) -> Vec<u8> {
        encode_domain_name(&self.rdata)
    }
}

impl CnameRdata {
    pub fn from(rdata: String) -> CnameRdata
    {
        CnameRdata {
            rdata
        }
    }
}