use core::net::IpAddr;
use embedded_nal::AddrType;
pub trait Dns {
type Error: core::fmt::Debug;
async fn get_host_by_name(
&self,
host: &str,
addr_type: AddrType,
) -> Result<IpAddr, Self::Error>;
async fn get_host_by_address(
&self,
addr: IpAddr,
result: &mut [u8],
) -> Result<usize, Self::Error>;
}
impl<T: Dns> Dns for &T {
type Error = T::Error;
async fn get_host_by_name(
&self,
host: &str,
addr_type: AddrType,
) -> Result<IpAddr, Self::Error> {
T::get_host_by_name(self, host, addr_type).await
}
async fn get_host_by_address(
&self,
addr: IpAddr,
result: &mut [u8],
) -> Result<usize, Self::Error> {
T::get_host_by_address(self, addr, result).await
}
}