dnslib/dto/
domain_request.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use hickory_proto::rr::RecordType;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DomainRequest {
    pub domain: String,
    pub rdata_type: String,
    pub rdata_content : Option<String>
}

impl DomainRequest {
    pub fn from_str(&self)-> RecordType {
        let rr_type = match self.rdata_type.as_str() {
            "A" => RecordType::A,
            "AAAA" => RecordType::AAAA,
            "MX" => RecordType::MX,
            "CNAME" => RecordType::CNAME,
            "TXT" => RecordType::TXT,
            _ => RecordType::Unknown(0),
        };
        rr_type
    }
}