Skip to content

Commit 33e8c08

Browse files
committed
Add a noop Dns impl
1 parent a1127f8 commit 33e8c08

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/nal.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,13 @@ pub mod std {
5656
/// All of these panic when called
5757
// TODO: Move to `edge-nal`
5858
pub mod noop {
59-
use core::{
60-
convert::Infallible,
61-
net::{Ipv4Addr, SocketAddr},
62-
};
59+
use core::convert::Infallible;
60+
use core::net::{IpAddr, Ipv4Addr, SocketAddr};
6361

6462
use edge_nal::io::{ErrorType, Read, Write};
6563
use edge_nal::{
66-
Close, MulticastV4, MulticastV6, Readable, TcpAccept, TcpBind, TcpConnect, TcpShutdown,
67-
TcpSplit, UdpBind, UdpConnect, UdpReceive, UdpSend, UdpSplit,
64+
AddrType, Close, Dns, MulticastV4, MulticastV6, Readable, TcpAccept, TcpBind, TcpConnect,
65+
TcpShutdown, TcpSplit, UdpBind, UdpConnect, UdpReceive, UdpSend, UdpSplit,
6866
};
6967

7068
/// A type that implements all `edge-nal` traits but does not support any operation
@@ -140,6 +138,26 @@ pub mod noop {
140138
}
141139
}
142140

141+
impl Dns for NoopNet {
142+
type Error = Infallible;
143+
144+
async fn get_host_by_name(
145+
&self,
146+
_host: &str,
147+
_addr_type: AddrType,
148+
) -> Result<IpAddr, Self::Error> {
149+
panic!("DNS get_host_by_name not supported")
150+
}
151+
152+
async fn get_host_by_address(
153+
&self,
154+
_addr: IpAddr,
155+
_result: &mut [u8],
156+
) -> Result<usize, Self::Error> {
157+
panic!("DNS get_host_by_address not supported")
158+
}
159+
}
160+
143161
impl ErrorType for NoopNet {
144162
type Error = Infallible;
145163
}

0 commit comments

Comments
 (0)