Skip to content

Commit b6608ee

Browse files
committed
uefi-raw: rename imports: use Std prefix
This will help in the following to better distinct between all the types from core::net (Std prefix) and EFI (no prefix).
1 parent 020674e commit b6608ee

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

uefi-raw/src/net.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
//! - [`Ipv4Address`]
99
//! - [`Ipv6Address`]
1010
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};
1313

1414
/// An IPv4 internet protocol address.
1515
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
@@ -24,13 +24,13 @@ impl Ipv4Address {
2424
}
2525
}
2626

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 {
2929
Self(ip.octets())
3030
}
3131
}
3232

33-
impl From<Ipv4Address> for core::net::Ipv4Addr {
33+
impl From<Ipv4Address> for StdIpv4Addr {
3434
fn from(ip: Ipv4Address) -> Self {
3535
Self::from(ip.0)
3636
}
@@ -49,13 +49,13 @@ impl Ipv6Address {
4949
}
5050
}
5151

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 {
5454
Self(ip.octets())
5555
}
5656
}
5757

58-
impl From<Ipv6Address> for core::net::Ipv6Addr {
58+
impl From<Ipv6Address> for StdIpv6Addr {
5959
fn from(ip: Ipv6Address) -> Self {
6060
Self::from(ip.0)
6161
}
@@ -115,13 +115,13 @@ impl Default for IpAddress {
115115
}
116116
}
117117

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 {
120120
match t {
121-
core::net::IpAddr::V4(ip) => Self {
121+
StdIpAddr::V4(ip) => Self {
122122
v4: Ipv4Address::from(ip),
123123
},
124-
core::net::IpAddr::V6(ip) => Self {
124+
StdIpAddr::V6(ip) => Self {
125125
v6: Ipv6Address::from(ip),
126126
},
127127
}
@@ -173,32 +173,32 @@ mod tests {
173173
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
174174
];
175175

176-
/// Test round-trip conversion between `Ipv4Address` and `core::net::Ipv4Addr`.
176+
/// Test round-trip conversion between [`Ipv4Address`] and [`StdIpv4Addr`].
177177
#[test]
178178
fn test_ip_addr4_conversion() {
179179
let uefi_addr = Ipv4Address(TEST_IPV4);
180-
let core_addr = core::net::Ipv4Addr::from(uefi_addr);
180+
let core_addr = StdIpv4Addr::from(uefi_addr);
181181
assert_eq!(uefi_addr, Ipv4Address::from(core_addr));
182182
}
183183

184-
/// Test round-trip conversion between `Ipv6Address` and `core::net::Ipv6Addr`.
184+
/// Test round-trip conversion between [`Ipv6Address`] and [`StdIpv6Addr`].
185185
#[test]
186186
fn test_ip_addr6_conversion() {
187187
let uefi_addr = Ipv6Address(TEST_IPV6);
188-
let core_addr = core::net::Ipv6Addr::from(uefi_addr);
188+
let core_addr = StdIpv6Addr::from(uefi_addr);
189189
assert_eq!(uefi_addr, Ipv6Address::from(core_addr));
190190
}
191191

192-
/// Test conversion from `core::net::IpAddr` to `IpvAddress`.
192+
/// Test conversion from [`StdIpAddr`] to [`IpvAddress`].
193193
///
194194
/// Note that conversion in the other direction is not possible.
195195
#[test]
196196
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));
198198
let uefi_addr = IpAddress::from(core_addr);
199199
assert_eq!(unsafe { uefi_addr.v4.0 }, TEST_IPV4);
200200

201-
let core_addr = core::net::IpAddr::V6(core::net::Ipv6Addr::from(TEST_IPV6));
201+
let core_addr = StdIpAddr::V6(StdIpv6Addr::from(TEST_IPV6));
202202
let uefi_addr = IpAddress::from(core_addr);
203203
assert_eq!(unsafe { uefi_addr.v6.0 }, TEST_IPV6);
204204
}

0 commit comments

Comments
 (0)