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
31
32
33
34
35
36
37
use std::fmt;
#[doc(hidden)]
pub type DnsResults = Vec<DnsResult>;
#[derive(Debug, Clone)]
pub struct DnsResult {
#[doc(hidden)]
pub src: String,
#[doc(hidden)]
pub result: DnsResultType,
}
impl fmt::Display for DnsResult {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "[src_ip[{}] {}]", self.src, self.result)
}
}
#[derive(Debug, Clone)]
pub enum DnsResultType {
Host(String),
Addr(Vec<std::net::IpAddr>),
Error(String),
}
impl fmt::Display for DnsResultType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let result = match self {
DnsResultType::Host(data) => format!("Host[{}]",data),
DnsResultType::Addr(data) => format!("Addr[{:?}]", data),
DnsResultType::Error(e) => format!("Err[{}]",e),
};
write!(f, "{}", result)
}
}