8
8
//! - [`Ipv4Address`]
9
9
//! - [`Ipv6Address`]
10
10
11
- use core:: fmt;
12
- use core:: fmt :: { Debug , Formatter } ;
11
+ use core:: fmt:: { self , Debug , Formatter } ;
12
+ use core:: net :: { IpAddr as StdIpAddr , Ipv4Addr as StdIpv4Addr , Ipv6Addr as StdIpv6Addr } ;
13
13
14
14
/// An IPv4 internet protocol address.
15
15
#[ derive( Clone , Copy , Debug , Default , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
@@ -24,13 +24,13 @@ impl Ipv4Address {
24
24
}
25
25
}
26
26
27
- impl From < core :: net :: Ipv4Addr > for Ipv4Address {
28
- fn from ( ip : core :: net :: Ipv4Addr ) -> Self {
27
+ impl From < StdIpv4Addr > for Ipv4Address {
28
+ fn from ( ip : StdIpv4Addr ) -> Self {
29
29
Self ( ip. octets ( ) )
30
30
}
31
31
}
32
32
33
- impl From < Ipv4Address > for core :: net :: Ipv4Addr {
33
+ impl From < Ipv4Address > for StdIpv4Addr {
34
34
fn from ( ip : Ipv4Address ) -> Self {
35
35
Self :: from ( ip. 0 )
36
36
}
@@ -49,13 +49,13 @@ impl Ipv6Address {
49
49
}
50
50
}
51
51
52
- impl From < core :: net :: Ipv6Addr > for Ipv6Address {
53
- fn from ( ip : core :: net :: Ipv6Addr ) -> Self {
52
+ impl From < StdIpv6Addr > for Ipv6Address {
53
+ fn from ( ip : StdIpv6Addr ) -> Self {
54
54
Self ( ip. octets ( ) )
55
55
}
56
56
}
57
57
58
- impl From < Ipv6Address > for core :: net :: Ipv6Addr {
58
+ impl From < Ipv6Address > for StdIpv6Addr {
59
59
fn from ( ip : Ipv6Address ) -> Self {
60
60
Self :: from ( ip. 0 )
61
61
}
@@ -115,13 +115,13 @@ impl Default for IpAddress {
115
115
}
116
116
}
117
117
118
- impl From < core :: net :: IpAddr > for IpAddress {
119
- fn from ( t : core :: net :: IpAddr ) -> Self {
118
+ impl From < StdIpAddr > for IpAddress {
119
+ fn from ( t : StdIpAddr ) -> Self {
120
120
match t {
121
- core :: net :: IpAddr :: V4 ( ip) => Self {
121
+ StdIpAddr :: V4 ( ip) => Self {
122
122
v4 : Ipv4Address :: from ( ip) ,
123
123
} ,
124
- core :: net :: IpAddr :: V6 ( ip) => Self {
124
+ StdIpAddr :: V6 ( ip) => Self {
125
125
v6 : Ipv6Address :: from ( ip) ,
126
126
} ,
127
127
}
@@ -173,32 +173,32 @@ mod tests {
173
173
101 , 102 , 103 , 104 , 105 , 106 , 107 , 108 , 109 , 110 , 111 , 112 , 113 , 114 , 115 , 116 ,
174
174
] ;
175
175
176
- /// Test round-trip conversion between `Ipv4Address` and `core::net::Ipv4Addr` .
176
+ /// Test round-trip conversion between [ `Ipv4Address`] and [`StdIpv4Addr`] .
177
177
#[ test]
178
178
fn test_ip_addr4_conversion ( ) {
179
179
let uefi_addr = Ipv4Address ( TEST_IPV4 ) ;
180
- let core_addr = core :: net :: Ipv4Addr :: from ( uefi_addr) ;
180
+ let core_addr = StdIpv4Addr :: from ( uefi_addr) ;
181
181
assert_eq ! ( uefi_addr, Ipv4Address :: from( core_addr) ) ;
182
182
}
183
183
184
- /// Test round-trip conversion between `Ipv6Address` and `core::net::Ipv6Addr` .
184
+ /// Test round-trip conversion between [ `Ipv6Address`] and [`StdIpv6Addr`] .
185
185
#[ test]
186
186
fn test_ip_addr6_conversion ( ) {
187
187
let uefi_addr = Ipv6Address ( TEST_IPV6 ) ;
188
- let core_addr = core :: net :: Ipv6Addr :: from ( uefi_addr) ;
188
+ let core_addr = StdIpv6Addr :: from ( uefi_addr) ;
189
189
assert_eq ! ( uefi_addr, Ipv6Address :: from( core_addr) ) ;
190
190
}
191
191
192
- /// Test conversion from `core::net::IpAddr` to `IpvAddress`.
192
+ /// Test conversion from [`StdIpAddr`] to [ `IpvAddress`] .
193
193
///
194
194
/// Note that conversion in the other direction is not possible.
195
195
#[ test]
196
196
fn test_ip_addr_conversion ( ) {
197
- let core_addr = core :: net :: IpAddr :: V4 ( core :: net :: Ipv4Addr :: from ( TEST_IPV4 ) ) ;
197
+ let core_addr = StdIpAddr :: V4 ( StdIpv4Addr :: from ( TEST_IPV4 ) ) ;
198
198
let uefi_addr = IpAddress :: from ( core_addr) ;
199
199
assert_eq ! ( unsafe { uefi_addr. v4. 0 } , TEST_IPV4 ) ;
200
200
201
- let core_addr = core :: net :: IpAddr :: V6 ( core :: net :: Ipv6Addr :: from ( TEST_IPV6 ) ) ;
201
+ let core_addr = StdIpAddr :: V6 ( StdIpv6Addr :: from ( TEST_IPV6 ) ) ;
202
202
let uefi_addr = IpAddress :: from ( core_addr) ;
203
203
assert_eq ! ( unsafe { uefi_addr. v6. 0 } , TEST_IPV6 ) ;
204
204
}
0 commit comments