@@ -11,7 +11,7 @@ use std::str::FromStr;
1111use std:: time:: Duration ;
1212use tokio:: runtime;
1313#[ doc( inline) ]
14- pub use tokio_postgres:: config:: { ChannelBinding , SslMode , TargetSessionAttrs } ;
14+ pub use tokio_postgres:: config:: { ChannelBinding , Host , SslMode , TargetSessionAttrs } ;
1515use tokio_postgres:: tls:: { MakeTlsConnect , TlsConnect } ;
1616use tokio_postgres:: { Error , Socket } ;
1717
@@ -123,6 +123,12 @@ impl Config {
123123 self
124124 }
125125
126+ /// Gets the user to authenticate with, if one has been configured with
127+ /// the `user` method.
128+ pub fn get_user ( & self ) -> Option < & str > {
129+ self . config . get_user ( )
130+ }
131+
126132 /// Sets the password to authenticate with.
127133 pub fn password < T > ( & mut self , password : T ) -> & mut Config
128134 where
@@ -132,6 +138,12 @@ impl Config {
132138 self
133139 }
134140
141+ /// Gets the password to authenticate with, if one has been configured with
142+ /// the `password` method.
143+ pub fn get_password ( & self ) -> Option < & [ u8 ] > {
144+ self . config . get_password ( )
145+ }
146+
135147 /// Sets the name of the database to connect to.
136148 ///
137149 /// Defaults to the user.
@@ -140,18 +152,36 @@ impl Config {
140152 self
141153 }
142154
155+ /// Gets the name of the database to connect to, if one has been configured
156+ /// with the `dbname` method.
157+ pub fn get_dbname ( & self ) -> Option < & str > {
158+ self . config . get_dbname ( )
159+ }
160+
143161 /// Sets command line options used to configure the server.
144162 pub fn options ( & mut self , options : & str ) -> & mut Config {
145163 self . config . options ( options) ;
146164 self
147165 }
148166
167+ /// Gets the command line options used to configure the server, if the
168+ /// options have been set with the `options` method.
169+ pub fn get_options ( & self ) -> Option < & str > {
170+ self . config . get_options ( )
171+ }
172+
149173 /// Sets the value of the `application_name` runtime parameter.
150174 pub fn application_name ( & mut self , application_name : & str ) -> & mut Config {
151175 self . config . application_name ( application_name) ;
152176 self
153177 }
154178
179+ /// Gets the value of the `application_name` runtime parameter, if it has
180+ /// been set with the `application_name` method.
181+ pub fn get_application_name ( & self ) -> Option < & str > {
182+ self . config . get_application_name ( )
183+ }
184+
155185 /// Sets the SSL configuration.
156186 ///
157187 /// Defaults to `prefer`.
@@ -160,6 +190,11 @@ impl Config {
160190 self
161191 }
162192
193+ /// Gets the SSL configuration.
194+ pub fn get_ssl_mode ( & self ) -> SslMode {
195+ self . config . get_ssl_mode ( )
196+ }
197+
163198 /// Adds a host to the configuration.
164199 ///
165200 /// Multiple hosts can be specified by calling this method multiple times, and each will be tried in order. On Unix
@@ -169,6 +204,11 @@ impl Config {
169204 self
170205 }
171206
207+ /// Gets the hosts that have been added to the configuration with `host`.
208+ pub fn get_hosts ( & self ) -> & [ Host ] {
209+ self . config . get_hosts ( )
210+ }
211+
172212 /// Adds a Unix socket host to the configuration.
173213 ///
174214 /// Unlike `host`, this method allows non-UTF8 paths.
@@ -191,6 +231,11 @@ impl Config {
191231 self
192232 }
193233
234+ /// Gets the ports that have been added to the configuration with `port`.
235+ pub fn get_ports ( & self ) -> & [ u16 ] {
236+ self . config . get_ports ( )
237+ }
238+
194239 /// Sets the timeout applied to socket-level connection attempts.
195240 ///
196241 /// Note that hostnames can resolve to multiple IP addresses, and this timeout will apply to each address of each
@@ -200,6 +245,12 @@ impl Config {
200245 self
201246 }
202247
248+ /// Gets the connection timeout, if one has been set with the
249+ /// `connect_timeout` method.
250+ pub fn get_connect_timeout ( & self ) -> Option < & Duration > {
251+ self . config . get_connect_timeout ( )
252+ }
253+
203254 /// Controls the use of TCP keepalive.
204255 ///
205256 /// This is ignored for Unix domain socket connections. Defaults to `true`.
@@ -208,6 +259,11 @@ impl Config {
208259 self
209260 }
210261
262+ /// Reports whether TCP keepalives will be used.
263+ pub fn get_keepalives ( & self ) -> bool {
264+ self . config . get_keepalives ( )
265+ }
266+
211267 /// Sets the amount of idle time before a keepalive packet is sent on the connection.
212268 ///
213269 /// This is ignored for Unix domain sockets, or if the `keepalives` option is disabled. Defaults to 2 hours.
@@ -216,6 +272,12 @@ impl Config {
216272 self
217273 }
218274
275+ /// Gets the configured amount of idle time before a keepalive packet will
276+ /// be sent on the connection.
277+ pub fn get_keepalives_idle ( & self ) -> Duration {
278+ self . config . get_keepalives_idle ( )
279+ }
280+
219281 /// Sets the requirements of the session.
220282 ///
221283 /// This can be used to connect to the primary server in a clustered database rather than one of the read-only
@@ -228,6 +290,11 @@ impl Config {
228290 self
229291 }
230292
293+ /// Gets the requirements of the session.
294+ pub fn get_target_session_attrs ( & self ) -> TargetSessionAttrs {
295+ self . config . get_target_session_attrs ( )
296+ }
297+
231298 /// Sets the channel binding behavior.
232299 ///
233300 /// Defaults to `prefer`.
@@ -236,6 +303,11 @@ impl Config {
236303 self
237304 }
238305
306+ /// Gets the channel binding behavior.
307+ pub fn get_channel_binding ( & self ) -> ChannelBinding {
308+ self . config . get_channel_binding ( )
309+ }
310+
239311 /// Opens a connection to a PostgreSQL database.
240312 pub fn connect < T > ( & self , tls : T ) -> Result < Client , Error >
241313 where
0 commit comments