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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#![cfg_attr(feature = "no-std", no_std)]
#[cfg(unix)]
mod unix;
#[cfg(windows)]
mod windows;
#[cfg(unix)]
pub use crate::unix::*;
#[cfg(windows)]
pub use crate::windows::*;
impl From<in_addr> for InAddr {
fn from(in_addr: in_addr) -> Self {
InAddr(in_addr)
}
}
impl From<InAddr> for in_addr {
fn from(InAddr(addr): InAddr) -> Self {
addr
}
}
#[cfg(not(feature = "no-std"))]
impl std::fmt::Debug for InAddr {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
Into::<std::net::Ipv4Addr>::into(*self).fmt(formatter)
}
}
#[cfg(not(feature = "no-std"))]
impl From<std::net::Ipv4Addr> for InAddr {
fn from(addr: std::net::Ipv4Addr) -> Self {
Into::<u32>::into(addr).into()
}
}
#[cfg(not(feature = "no-std"))]
impl From<InAddr> for std::net::Ipv4Addr {
fn from(addr: InAddr) -> Self {
Into::<u32>::into(addr).into()
}
}