Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita454378

Browse files
committed
Restore back compat
1 parentf777f74 commita454378

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

‎postgres/src/config.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,12 @@ impl Config {
150150
}
151151

152152
/// Gets the user to authenticate with.
153+
///
153154
/// If no user has been configured with the [`user`](Config::user) method,
154-
/// then this defaults to the user executing this process.
155-
pubfnget_user(&self) ->&str{
155+
/// then this defaults to the user executing this process. It always
156+
/// returns `Some`.
157+
// FIXME remove option
158+
pubfnget_user(&self) ->Option<&str>{
156159
self.config.get_user()
157160
}
158161

‎tokio-postgres/src/config.rs‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ pub enum Host {
190190
/// ```
191191
#[derive(Clone,PartialEq,Eq)]
192192
pubstructConfig{
193-
user:String,
193+
pub(crate)user:String,
194194
pub(crate)password:Option<Vec<u8>>,
195195
pub(crate)dbname:Option<String>,
196196
pub(crate)options:Option<String>,
@@ -245,17 +245,20 @@ impl Config {
245245

246246
/// Sets the user to authenticate with.
247247
///
248-
///If the user is not set, then this defaults to the user executing this process.
248+
///Defaults to the user executing this process.
249249
pubfnuser(&mutself,user:&str) ->&mutConfig{
250250
self.user = user.to_string();
251251
self
252252
}
253253

254254
/// Gets the user to authenticate with.
255+
///
255256
/// If no user has been configured with the [`user`](Config::user) method,
256-
/// then this defaults to the user executing this process.
257-
pubfnget_user(&self) ->&str{
258-
&self.user
257+
/// then this defaults to the user executing this process. It always
258+
/// returns `Some`.
259+
// FIXME remove option
260+
pubfnget_user(&self) ->Option<&str>{
261+
Some(&self.user)
259262
}
260263

261264
/// Sets the password to authenticate with.
@@ -1125,7 +1128,7 @@ mod tests {
11251128
fntest_simple_parsing(){
11261129
let s ="user=pass_user dbname=postgres host=host1,host2 hostaddr=127.0.0.1,127.0.0.2 port=26257";
11271130
let config = s.parse::<Config>().unwrap();
1128-
assert_eq!("pass_user", config.get_user());
1131+
assert_eq!(Some("pass_user"), config.get_user());
11291132
assert_eq!(Some("postgres"), config.get_dbname());
11301133
assert_eq!(
11311134
[

‎tokio-postgres/src/connect_raw.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ where
113113
T:AsyncRead +AsyncWrite +Unpin,
114114
{
115115
letmut params =vec![("client_encoding","UTF8")];
116-
params.push(("user", config.get_user()));
116+
params.push(("user",&config.user));
117117
ifletSome(dbname) =&config.dbname{
118118
params.push(("database",&**dbname));
119119
}
@@ -156,7 +156,7 @@ where
156156
Some(Message::AuthenticationMd5Password(body)) =>{
157157
can_skip_channel_binding(config)?;
158158

159-
let user = config.get_user();
159+
let user =&config.user;
160160
let pass = config
161161
.password
162162
.as_ref()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp