Skip to content

Commit c65a5ca

Browse files
committed
Implemented Display for human‑friendly formatting of discovered devices
1 parent c5c7ae1 commit c65a5ca

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/types.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::fmt;
2+
13
#[derive(Debug, Clone, Copy, PartialEq)]
24
pub enum CipType {
35
Bool = 0xC1,
@@ -66,6 +68,24 @@ pub struct DiscoveredIdentity {
6668
pub product_name: String,
6769
}
6870

71+
impl fmt::Display for DiscoveredIdentity {
72+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
73+
write!(
74+
f,
75+
"{} — {} (Vendor: {}, Type: {}, Code: {}, Rev: {}.{}, Serial: {}, Status: 0x{:04X})",
76+
self.ip,
77+
self.product_name,
78+
self.vendor_id,
79+
self.device_type,
80+
self.product_code,
81+
self.revision_major,
82+
self.revision_minor,
83+
self.serial,
84+
self.status
85+
)
86+
}
87+
}
88+
6989
#[derive(Debug, Clone, PartialEq)]
7090
pub struct IdentityInfo {
7191
pub vendor_id: u16,

0 commit comments

Comments
 (0)