Skip to content

Commit cede821

Browse files
committed
uefi-raw: implement Display for Ipv4Address and Ipv6Address
1 parent 8fc2097 commit cede821

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

uefi-raw/src/net.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! - [`Ipv4Address`]
99
//! - [`Ipv6Address`]
1010
11-
use core::fmt::{self, Debug, Formatter};
11+
use core::fmt::{self, Debug, Display, Formatter};
1212

1313
/// An IPv4 internet protocol address.
1414
///
@@ -48,6 +48,13 @@ impl From<[u8; 4]> for Ipv4Address {
4848
}
4949
}
5050

51+
impl Display for Ipv4Address {
52+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
53+
let ip = core::net::Ipv4Addr::from(*self);
54+
write!(f, "{}", ip)
55+
}
56+
}
57+
5158
/// An IPv6 internet protocol address.
5259
///
5360
/// # Conversions and Relation to [`core::net`]
@@ -86,6 +93,13 @@ impl From<[u8; 16]> for Ipv6Address {
8693
}
8794
}
8895

96+
impl Display for Ipv6Address {
97+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
98+
let ip = core::net::Ipv6Addr::from(*self);
99+
write!(f, "{}", ip)
100+
}
101+
}
102+
89103
/// An IPv4 or IPv6 internet protocol address that is ABI compatible with EFI.
90104
///
91105
/// Corresponds to the `EFI_IP_ADDRESS` type in the UEFI specification. This

0 commit comments

Comments
 (0)