nodecraft/resolver/
impls.rs1#[cfg(feature = "dns")]
3#[cfg_attr(docsrs, doc(cfg(feature = "dns")))]
4pub mod dns;
5
6#[cfg(all(feature = "std", feature = "async"))]
8#[cfg_attr(docsrs, doc(cfg(all(feature = "std", feature = "async"))))]
9pub mod socket_addr;
10
11#[cfg(all(feature = "std", feature = "async"))]
14#[cfg_attr(docsrs, doc(cfg(all(feature = "std", feature = "async"))))]
15pub mod address;
16
17#[cfg(all(feature = "std", feature = "async"))]
18struct CachedSocketAddr {
19 val: std::net::SocketAddr,
20 born: std::time::Instant,
21 ttl: std::time::Duration,
22}
23
24#[cfg(all(feature = "std", feature = "async"))]
25impl CachedSocketAddr {
26 fn new(val: std::net::SocketAddr, ttl: std::time::Duration) -> Self {
27 Self {
28 val,
29 born: std::time::Instant::now(),
30 ttl,
31 }
32 }
33
34 fn is_expired(&self) -> bool {
35 self.born.elapsed() > self.ttl
36 }
37}