Skip to content

Commit ac3bee8

Browse files
committed
uefi-raw: net: implement Display for Ipv4Address and Ipv6Address
1 parent ecf8f89 commit ac3bee8

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
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
@@ -35,6 +35,13 @@ impl From<Ipv4Address> for core::net::Ipv4Addr {
3535
}
3636
}
3737

38+
impl Display for Ipv4Address {
39+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
40+
let ip = core::net::Ipv4Addr::from(*self);
41+
write!(f, "{}", ip)
42+
}
43+
}
44+
3845
/// An IPv6 internet protocol address.
3946
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
4047
#[repr(transparent)]
@@ -60,6 +67,13 @@ impl From<Ipv6Address> for core::net::Ipv6Addr {
6067
}
6168
}
6269

70+
impl Display for Ipv6Address {
71+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
72+
let ip = core::net::Ipv6Addr::from(*self);
73+
write!(f, "{}", ip)
74+
}
75+
}
76+
6377
/// An IPv4 or IPv6 internet protocol address that is ABI compatible with EFI.
6478
///
6579
/// Corresponds to the `EFI_IP_ADDRESS` type in the UEFI specification. This

0 commit comments

Comments
 (0)