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
}
@@ -125,13 +125,13 @@ impl Default for IpAddress {
125
125
}
126
126
}
127
127
128
- impl From < core :: net :: IpAddr > for IpAddress {
129
- fn from ( t : core :: net :: IpAddr ) -> Self {
128
+ impl From < StdIpAddr > for IpAddress {
129
+ fn from ( t : StdIpAddr ) -> Self {
130
130
match t {
131
- core :: net :: IpAddr :: V4 ( ip) => Self {
131
+ StdIpAddr :: V4 ( ip) => Self {
132
132
v4 : Ipv4Address :: from ( ip) ,
133
133
} ,
134
- core :: net :: IpAddr :: V6 ( ip) => Self {
134
+ StdIpAddr :: V6 ( ip) => Self {
135
135
v6 : Ipv6Address :: from ( ip) ,
136
136
} ,
137
137
}
@@ -188,32 +188,32 @@ mod tests {
188
188
101 , 102 , 103 , 104 , 105 , 106 , 107 , 108 , 109 , 110 , 111 , 112 , 113 , 114 , 115 , 116 ,
189
189
] ;
190
190
191
- /// Test round-trip conversion between `Ipv4Address` and `core::net::Ipv4Addr` .
191
+ /// Test round-trip conversion between [ `Ipv4Address`] and [`StdIpv4Addr`] .
192
192
#[ test]
193
193
fn test_ip_addr4_conversion ( ) {
194
194
let uefi_addr = Ipv4Address ( TEST_IPV4 ) ;
195
- let core_addr = core :: net :: Ipv4Addr :: from ( uefi_addr) ;
195
+ let core_addr = StdIpv4Addr :: from ( uefi_addr) ;
196
196
assert_eq ! ( uefi_addr, Ipv4Address :: from( core_addr) ) ;
197
197
}
198
198
199
- /// Test round-trip conversion between `Ipv6Address` and `core::net::Ipv6Addr` .
199
+ /// Test round-trip conversion between [ `Ipv6Address`] and [`StdIpv6Addr`] .
200
200
#[ test]
201
201
fn test_ip_addr6_conversion ( ) {
202
202
let uefi_addr = Ipv6Address ( TEST_IPV6 ) ;
203
- let core_addr = core :: net :: Ipv6Addr :: from ( uefi_addr) ;
203
+ let core_addr = StdIpv6Addr :: from ( uefi_addr) ;
204
204
assert_eq ! ( uefi_addr, Ipv6Address :: from( core_addr) ) ;
205
205
}
206
206
207
- /// Test conversion from `core::net::IpAddr` to `IpvAddress`.
207
+ /// Test conversion from [`StdIpAddr`] to [ `IpvAddress`] .
208
208
///
209
209
/// Note that conversion in the other direction is not possible.
210
210
#[ test]
211
211
fn test_ip_addr_conversion ( ) {
212
- let core_addr = core :: net :: IpAddr :: V4 ( core :: net :: Ipv4Addr :: from ( TEST_IPV4 ) ) ;
212
+ let core_addr = StdIpAddr :: V4 ( StdIpv4Addr :: from ( TEST_IPV4 ) ) ;
213
213
let uefi_addr = IpAddress :: from ( core_addr) ;
214
214
assert_eq ! ( unsafe { uefi_addr. v4. 0 } , TEST_IPV4 ) ;
215
215
216
- let core_addr = core :: net :: IpAddr :: V6 ( core :: net :: Ipv6Addr :: from ( TEST_IPV6 ) ) ;
216
+ let core_addr = StdIpAddr :: V6 ( StdIpv6Addr :: from ( TEST_IPV6 ) ) ;
217
217
let uefi_addr = IpAddress :: from ( core_addr) ;
218
218
assert_eq ! ( unsafe { uefi_addr. v6. 0 } , TEST_IPV6 ) ;
219
219
}
0 commit comments