@@ -144,6 +144,7 @@ impl Default for Config {
144
144
}
145
145
146
146
impl Config {
147
+ /// Creates a new configuration.
147
148
pub fn new ( ) -> Config {
148
149
Config ( Arc :: new ( Inner {
149
150
user : None ,
@@ -166,11 +167,15 @@ impl Config {
166
167
} ) )
167
168
}
168
169
170
+ /// Sets the user to authenticate with.
171
+ ///
172
+ /// Required.
169
173
pub fn user ( & mut self , user : & str ) -> & mut Config {
170
174
Arc :: make_mut ( & mut self . 0 ) . user = Some ( user. to_string ( ) ) ;
171
175
self
172
176
}
173
177
178
+ /// Sets the password to authenticate with.
174
179
pub fn password < T > ( & mut self , password : T ) -> & mut Config
175
180
where
176
181
T : AsRef < [ u8 ] > ,
@@ -179,21 +184,32 @@ impl Config {
179
184
self
180
185
}
181
186
187
+ /// Sets the name of the database to connect to.
188
+ ///
189
+ /// Defaults to the user.
182
190
pub fn dbname ( & mut self , dbname : & str ) -> & mut Config {
183
191
Arc :: make_mut ( & mut self . 0 ) . dbname = Some ( dbname. to_string ( ) ) ;
184
192
self
185
193
}
186
194
195
+ /// Sets command line options used to configure the server.
187
196
pub fn options ( & mut self , options : & str ) -> & mut Config {
188
197
Arc :: make_mut ( & mut self . 0 ) . options = Some ( options. to_string ( ) ) ;
189
198
self
190
199
}
191
200
201
+ /// Sets the value of the `application_name` runtime parameter.
192
202
pub fn application_name ( & mut self , application_name : & str ) -> & mut Config {
193
203
Arc :: make_mut ( & mut self . 0 ) . application_name = Some ( application_name. to_string ( ) ) ;
194
204
self
195
205
}
196
206
207
+ /// Adds a host to the configuration.
208
+ ///
209
+ /// Multiple hosts can be specified by calling this method multiple times, and each will be tried in order. On Unix
210
+ /// systems, a host starting with a `/` is interpreted as a path to a directory containing Unix domain sockets.
211
+ ///
212
+ /// Requires the `runtime` Cargo feature (enabled by default).
197
213
#[ cfg( feature = "runtime" ) ]
198
214
pub fn host ( & mut self , host : & str ) -> & mut Config {
199
215
#[ cfg( unix) ]
@@ -209,6 +225,11 @@ impl Config {
209
225
self
210
226
}
211
227
228
+ /// Adds a Unix socket host to the configuration.
229
+ ///
230
+ /// Unlike `host`, this method allows non-UTF8 paths.
231
+ ///
232
+ /// Requires the `runtime` Cargo feature (enabled by default) and a Unix target.
212
233
#[ cfg( all( feature = "runtime" , unix) ) ]
213
234
pub fn host_path < T > ( & mut self , host : T ) -> & mut Config
214
235
where
@@ -220,6 +241,13 @@ impl Config {
220
241
self
221
242
}
222
243
244
+ /// Adds a port to the configuration.
245
+ ///
246
+ /// Multiple ports can be specified by calling this method multiple times. There must either be no ports, in which
247
+ /// case the default of 5432 is used, a single port, in which it is used for all hosts, or the same number of ports
248
+ /// as hosts.
249
+ ///
250
+ /// Requires the `runtime` Cargo feature (enabled by default).
223
251
#[ cfg( feature = "runtime" ) ]
224
252
pub fn port ( & mut self , port : u16 ) -> & mut Config {
225
253
Arc :: make_mut ( & mut self . 0 ) . port . push ( port) ;
0 commit comments