Skip to content

Commit

Permalink
net:eth: implement Display for Mac
Browse files Browse the repository at this point in the history
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
  • Loading branch information
Fredi-raspall authored and qmonnet committed Feb 13, 2025
1 parent 4e4cf6c commit 6981643
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions net/src/eth/mac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! Mac address type and logic.
use crate::eth::{DestinationMacAddressError, SourceMacAddressError};
use std::fmt::Display;

/// A [MAC Address] type.
///
Expand Down Expand Up @@ -120,6 +121,15 @@ impl Mac {
}
}

impl Display for Mac {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{:<02X}:{:<02X}:{:<02X}:{:<02X}:{:<02X}:{:<02X}",
self.0[0], self.0[1], self.0[2], self.0[3], self.0[4], self.0[5]
)
}
}
/// A [`Mac`] which is legal as a source in an ethernet header.
#[repr(transparent)]
pub struct SourceMac(Mac);
Expand Down

0 comments on commit 6981643

Please sign in to comment.