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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(unix)]
mod unix;
#[cfg(windows)]
mod windows;
#[cfg(unix)]
pub use crate::unix::*;
#[cfg(windows)]
pub use crate::windows::*;
impl InAddr {
pub fn new<T: Into<Self>>(t: T) -> Self {
t.into()
}
}
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(feature = "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(feature = "std")]
impl From<std::net::Ipv4Addr> for InAddr {
fn from(addr: std::net::Ipv4Addr) -> Self {
Into::<u32>::into(addr).into()
}
}
#[cfg(feature = "std")]
impl From<InAddr> for std::net::Ipv4Addr {
fn from(addr: InAddr) -> Self {
Into::<u32>::into(addr).into()
}
}