pci: Implementing Debug for PciBdf to aid with debugging

Signed-off-by: Arvind Vasudev <avasudev@crusoeenergy.com>
This commit is contained in:
Arvind Vasudev 2025-01-13 09:12:32 -08:00 committed by Rob Bradford
parent 2f9436bc12
commit 8c07294691

View File

@ -16,7 +16,7 @@ mod msix;
mod vfio;
mod vfio_user;
use std::fmt::{self, Display};
use std::fmt::{self, Debug, Display};
use std::num::ParseIntError;
use std::str::FromStr;
@ -152,6 +152,19 @@ impl From<&PciBdf> for u16 {
}
}
impl Debug for PciBdf {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{:04x}:{:02x}:{:02x}.{:01x}",
self.segment(),
self.bus(),
self.device(),
self.function()
)
}
}
impl Display for PciBdf {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(