@@ -197,12 +197,8 @@ impl ServerParameters {
197
197
key = "DateStyle" . to_string ( ) ;
198
198
} ;
199
199
200
- if TRACKED_PARAMETERS . contains ( & key) {
200
+ if TRACKED_PARAMETERS . contains ( & key) || startup {
201
201
self . parameters . insert ( key, value) ;
202
- } else {
203
- if startup {
204
- self . parameters . insert ( key, value) ;
205
- }
206
202
}
207
203
}
208
204
@@ -332,6 +328,7 @@ pub struct Server {
332
328
impl Server {
333
329
/// Pretend to be the Postgres client and connect to the server given host, port and credentials.
334
330
/// Perform the authentication and return the server in a ready for query state.
331
+ #[ allow( clippy:: too_many_arguments) ]
335
332
pub async fn startup (
336
333
address : & Address ,
337
334
user : & User ,
@@ -440,10 +437,7 @@ impl Server {
440
437
441
438
// Something else?
442
439
m => {
443
- return Err ( Error :: SocketError ( format ! (
444
- "Unknown message: {}" ,
445
- m as char
446
- ) ) ) ;
440
+ return Err ( Error :: SocketError ( format ! ( "Unknown message: {}" , { m } ) ) ) ;
447
441
}
448
442
}
449
443
} else {
@@ -461,6 +455,8 @@ impl Server {
461
455
None => & user. username ,
462
456
} ;
463
457
458
+ #[ allow( clippy:: match_as_ref) ]
459
+ #[ allow( clippy:: manual_map) ]
464
460
let password = match user. server_password {
465
461
Some ( ref server_password) => Some ( server_password) ,
466
462
None => match user. password {
@@ -473,14 +469,11 @@ impl Server {
473
469
474
470
let mut process_id: i32 = 0 ;
475
471
let mut secret_key: i32 = 0 ;
476
- let server_identifier = ServerIdentifier :: new ( username, & database) ;
472
+ let server_identifier = ServerIdentifier :: new ( username, database) ;
477
473
478
474
// We'll be handling multiple packets, but they will all be structured the same.
479
475
// We'll loop here until this exchange is complete.
480
- let mut scram: Option < ScramSha256 > = match password {
481
- Some ( password) => Some ( ScramSha256 :: new ( password) ) ,
482
- None => None ,
483
- } ;
476
+ let mut scram: Option < ScramSha256 > = password. map ( |password| ScramSha256 :: new ( password) ) ;
484
477
485
478
let mut server_parameters = ServerParameters :: new ( ) ;
486
479
@@ -882,7 +875,7 @@ impl Server {
882
875
self . mirror_send ( messages) ;
883
876
self . stats ( ) . data_sent ( messages. len ( ) ) ;
884
877
885
- match write_all_flush ( & mut self . stream , & messages) . await {
878
+ match write_all_flush ( & mut self . stream , messages) . await {
886
879
Ok ( _) => {
887
880
// Successfully sent to server
888
881
self . last_activity = SystemTime :: now ( ) ;
@@ -1359,16 +1352,14 @@ impl Server {
1359
1352
}
1360
1353
1361
1354
pub fn mirror_send ( & mut self , bytes : & BytesMut ) {
1362
- match self . mirror_manager . as_mut ( ) {
1363
- Some ( manager) => manager. send ( bytes) ,
1364
- None => ( ) ,
1355
+ if let Some ( manager) = self . mirror_manager . as_mut ( ) {
1356
+ manager. send ( bytes)
1365
1357
}
1366
1358
}
1367
1359
1368
1360
pub fn mirror_disconnect ( & mut self ) {
1369
- match self . mirror_manager . as_mut ( ) {
1370
- Some ( manager) => manager. disconnect ( ) ,
1371
- None => ( ) ,
1361
+ if let Some ( manager) = self . mirror_manager . as_mut ( ) {
1362
+ manager. disconnect ( )
1372
1363
}
1373
1364
}
1374
1365
@@ -1397,7 +1388,7 @@ impl Server {
1397
1388
server. send ( & simple_query ( query) ) . await ?;
1398
1389
let mut message = server. recv ( None ) . await ?;
1399
1390
1400
- Ok ( parse_query_message ( & mut message) . await ? )
1391
+ parse_query_message ( & mut message) . await
1401
1392
}
1402
1393
}
1403
1394
0 commit comments