@@ -796,7 +796,7 @@ impl fmt::Debug for dyn SerialPort {
796796}
797797
798798/// Contains all possible USB information about a `SerialPort`
799- #[ derive( Debug , Clone , PartialEq , Eq ) ]
799+ #[ derive( Clone , PartialEq , Eq ) ]
800800#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
801801pub struct UsbPortInfo {
802802 /// Vendor ID
@@ -816,6 +816,32 @@ pub struct UsbPortInfo {
816816 pub interface : Option < u8 > ,
817817}
818818
819+ struct HexU16 ( u16 ) ;
820+
821+ impl std:: fmt:: Debug for HexU16 {
822+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
823+ write ! ( f, "0x{:04x}" , self . 0 )
824+ }
825+ }
826+
827+ impl std:: fmt:: Debug for UsbPortInfo {
828+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
829+ let mut d = f. debug_struct ( "UsbPortInfo" ) ;
830+ d. field ( "vid" , & HexU16 ( self . vid ) )
831+ . field ( "pid" , & HexU16 ( self . pid ) )
832+ . field ( "serial_number" , & self . serial_number )
833+ . field ( "manufacturer" , & self . manufacturer )
834+ . field ( "product" , & self . product ) ;
835+
836+ #[ cfg( feature = "usbportinfo-interface" ) ]
837+ {
838+ d. field ( "interface" , & self . interface ) ;
839+ }
840+
841+ d. finish ( )
842+ }
843+ }
844+
819845/// The physical type of a `SerialPort`
820846#[ derive( Debug , Clone , PartialEq , Eq ) ]
821847#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
0 commit comments