@@ -69,45 +69,6 @@ pub(crate) struct Inner {
69
69
pub ( crate ) target_session_attrs : TargetSessionAttrs ,
70
70
}
71
71
72
- // Omit password from debug output
73
- impl fmt:: Debug for Inner {
74
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
75
- write ! (
76
- f,
77
- "Inner {{ \
78
- user: {:?}, \
79
- password: {}, \
80
- dbname: {:?}, \
81
- options: {:?}, \
82
- application_name: {:?}, \
83
- ssl_mode: {:?}, \
84
- host: {:?}, \
85
- port: {:?}, \
86
- connect_timeout: {:?}, \
87
- keepalives: {:?}, \
88
- keepalives_idle: {:?}, \
89
- target_session_attrs: {:?} \
90
- }}",
91
- self . user,
92
- if self . password. is_some( ) {
93
- "Some(_)"
94
- } else {
95
- "None"
96
- } ,
97
- self . dbname,
98
- self . options,
99
- self . application_name,
100
- self . ssl_mode,
101
- self . host,
102
- self . port,
103
- self . connect_timeout,
104
- self . keepalives,
105
- self . keepalives_idle,
106
- self . target_session_attrs
107
- )
108
- }
109
- }
110
-
111
72
/// Connection configuration.
112
73
///
113
74
/// Configuration can be parsed from libpq-style connection strings. These strings come in two formats:
@@ -181,7 +142,7 @@ impl fmt::Debug for Inner {
181
142
/// ```not_rust
182
143
/// postgresql:///mydb?user=user&host=/var/lib/postgresql
183
144
/// ```
184
- #[ derive( Debug , Clone , PartialEq ) ]
145
+ #[ derive( Clone , PartialEq ) ]
185
146
pub struct Config ( pub ( crate ) Arc < Inner > ) ;
186
147
187
148
impl Default for Config {
@@ -453,6 +414,33 @@ impl FromStr for Config {
453
414
}
454
415
}
455
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
+
456
444
#[ derive( Debug ) ]
457
445
struct UnknownOption ( String ) ;
458
446
0 commit comments