@@ -796,7 +796,7 @@ impl fmt::Debug for dyn SerialPort {
796
796
}
797
797
798
798
/// Contains all possible USB information about a `SerialPort`
799
- #[ derive( Debug , Clone , PartialEq , Eq ) ]
799
+ #[ derive( Clone , PartialEq , Eq ) ]
800
800
#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
801
801
pub struct UsbPortInfo {
802
802
/// Vendor ID
@@ -816,6 +816,32 @@ pub struct UsbPortInfo {
816
816
pub interface : Option < u8 > ,
817
817
}
818
818
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
+
819
845
/// The physical type of a `SerialPort`
820
846
#[ derive( Debug , Clone , PartialEq , Eq ) ]
821
847
#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
0 commit comments