@@ -53,7 +53,7 @@ pub(crate) enum Host {
5353 Unix ( PathBuf ) ,
5454}
5555
56- #[ derive( Debug , Clone , PartialEq ) ]
56+ #[ derive( Clone , PartialEq ) ]
5757pub ( crate ) struct Inner {
5858 pub ( crate ) user : Option < String > ,
5959 pub ( crate ) password : Option < Vec < u8 > > ,
@@ -142,7 +142,7 @@ pub(crate) struct Inner {
142142/// ```not_rust
143143/// postgresql:///mydb?user=user&host=/var/lib/postgresql
144144/// ```
145- #[ derive( Debug , Clone , PartialEq ) ]
145+ #[ derive( Clone , PartialEq ) ]
146146pub struct Config ( pub ( crate ) Arc < Inner > ) ;
147147
148148impl Default for Config {
@@ -414,6 +414,33 @@ impl FromStr for Config {
414414 }
415415}
416416
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+
417444#[ derive( Debug ) ]
418445struct UnknownOption ( String ) ;
419446
0 commit comments