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
use std::ffi::CString;
use std::net::IpAddr;
#[derive(Clone, Eq, PartialEq, Debug, Hash, PartialOrd, Ord)]
pub struct HostResults {
pub hostname: CString,
pub addresses: Vec<IpAddr>,
pub aliases: Vec<CString>,
}
impl<'a> From<c_ares::HostResults<'a>> for HostResults {
fn from(results: c_ares::HostResults) -> Self {
HostResults {
hostname: results.hostname().to_owned(),
addresses: results.addresses().collect(),
aliases: results
.aliases()
.map(std::borrow::ToOwned::to_owned)
.collect(),
}
}
}