@@ -53,7 +53,7 @@ pub(crate) enum Host {
53
53
Unix ( PathBuf ) ,
54
54
}
55
55
56
- #[ derive( Debug , Clone , PartialEq ) ]
56
+ #[ derive( Clone , PartialEq ) ]
57
57
pub ( crate ) struct Inner {
58
58
pub ( crate ) user : Option < String > ,
59
59
pub ( crate ) password : Option < Vec < u8 > > ,
@@ -142,7 +142,7 @@ pub(crate) struct Inner {
142
142
/// ```not_rust
143
143
/// postgresql:///mydb?user=user&host=/var/lib/postgresql
144
144
/// ```
145
- #[ derive( Debug , Clone , PartialEq ) ]
145
+ #[ derive( Clone , PartialEq ) ]
146
146
pub struct Config ( pub ( crate ) Arc < Inner > ) ;
147
147
148
148
impl Default for Config {
@@ -414,6 +414,33 @@ impl FromStr for Config {
414
414
}
415
415
}
416
416
417
+ // Omit password from debug output
418
+ impl fmt:: Debug for Config {
419
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
420
+ struct Redaction { }
421
+ impl fmt:: Debug for Redaction {
422
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
423
+ write ! ( f, "_" )
424
+ }
425
+ }
426
+
427
+ f. debug_struct ( "Config" )
428
+ . field ( "user" , & self . 0 . user )
429
+ . field ( "password" , & self . 0 . password . as_ref ( ) . map ( |_| Redaction { } ) )
430
+ . field ( "dbname" , & self . 0 . dbname )
431
+ . field ( "options" , & self . 0 . options )
432
+ . field ( "application_name" , & self . 0 . application_name )
433
+ . field ( "ssl_mode" , & self . 0 . ssl_mode )
434
+ . field ( "host" , & self . 0 . host )
435
+ . field ( "port" , & self . 0 . port )
436
+ . field ( "connect_timeout" , & self . 0 . connect_timeout )
437
+ . field ( "keepalives" , & self . 0 . keepalives )
438
+ . field ( "keepalives_idle" , & self . 0 . keepalives_idle )
439
+ . field ( "target_session_attrs" , & self . 0 . target_session_attrs )
440
+ . finish ( )
441
+ }
442
+ }
443
+
417
444
#[ derive( Debug ) ]
418
445
struct UnknownOption ( String ) ;
419
446
0 commit comments