Skip to content

Commit 754515d

Browse files
committed
Update rustfmt.toml to current
1 parent e53fb00 commit 754515d

File tree

8 files changed

+138
-120
lines changed

8 files changed

+138
-120
lines changed

.rustfmt.toml

-11
This file was deleted.

base-library/src/aws4.rs

+22-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
use chrono::{Date, DateTime, Duration, NaiveDate, NaiveDateTime, NaiveTime, Utc};
2-
use http::{
3-
header::{HeaderMap, HeaderName, HeaderValue},
4-
uri::{PathAndQuery, Uri},
1+
use {
2+
chrono::{Date, DateTime, Duration, NaiveDate, NaiveDateTime, NaiveTime, Utc},
3+
http::{
4+
header::{HeaderMap, HeaderName, HeaderValue},
5+
uri::{PathAndQuery, Uri},
6+
},
7+
log::debug,
8+
scratchstack_aws_principal::PrincipalActor,
9+
std::{
10+
env,
11+
fs::File,
12+
io::{BufRead, BufReader, Read},
13+
path::PathBuf,
14+
str::from_utf8,
15+
},
16+
tower::Service,
517
};
6-
use log::debug;
7-
use scratchstack_aws_principal::PrincipalActor;
8-
use std::{
9-
env,
10-
fs::File,
11-
io::{BufRead, BufReader, Read},
12-
path::PathBuf,
13-
str::from_utf8,
14-
};
15-
use tower::Service;
1618

17-
use crate::{get_signing_key_fn, sigv4_verify_at, Request, SignatureError, SigningKey, SigningKeyKind};
18-
use test_env_log;
19+
use {
20+
crate::{get_signing_key_fn, sigv4_verify_at, Request, SignatureError, SigningKey, SigningKeyKind},
21+
test_env_log,
22+
};
1923

2024
const TEST_REGION: &str = "us-east-1";
2125
const TEST_SERVICE: &str = "service";
@@ -406,8 +410,8 @@ fn parse_file(f: File, filename: &PathBuf) -> Request {
406410

407411
Request {
408412
request_method: method.to_string(),
409-
uri: uri,
410-
headers: headers,
413+
uri,
414+
headers,
411415
body: Some(body),
412416
}
413417
}

base-library/src/chronoutil.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
use std::{error::Error, str::FromStr};
22

3-
use chrono::format::{ParseError, ParseResult};
4-
use chrono::offset::{FixedOffset, TimeZone};
5-
use chrono::{DateTime, Utc};
6-
use lazy_static::lazy_static;
7-
use regex::Regex;
3+
use {
4+
chrono::{
5+
format::{ParseError, ParseResult},
6+
offset::{FixedOffset, TimeZone},
7+
DateTime, Utc,
8+
},
9+
lazy_static::lazy_static,
10+
regex::Regex,
11+
};
812

913
lazy_static! {
1014
/// ISO 8601 timestamp format

base-library/src/signature.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@ use std::{
1919
task::{Context, Poll},
2020
};
2121

22-
use chrono::{Date, DateTime, Duration, Utc};
23-
use http::{
24-
header::{HeaderMap, HeaderValue},
25-
request::Parts,
26-
Uri,
22+
use {
23+
chrono::{Date, DateTime, Duration, Utc},
24+
http::{
25+
header::{HeaderMap, HeaderValue},
26+
request::Parts,
27+
Uri,
28+
},
29+
lazy_static::lazy_static,
30+
log::trace,
31+
regex::Regex,
32+
ring::digest::{digest, SHA256},
33+
scratchstack_aws_principal::PrincipalActor,
34+
tower::{BoxError, Service},
2735
};
28-
use lazy_static::lazy_static;
29-
use log::trace;
30-
use regex::Regex;
31-
use ring::digest::{digest, SHA256};
32-
use scratchstack_aws_principal::PrincipalActor;
33-
use tower::{BoxError, Service};
34-
35-
use crate::chronoutil::parse_date_str;
36-
use crate::hmac::hmac_sha256;
36+
37+
use crate::{chronoutil::parse_date_str, hmac::hmac_sha256};
3738

3839
/// Content-Type string for HTML forms
3940
const APPLICATION_X_WWW_FORM_URLENCODED: &str = "application/x-www-form-urlencoded";

base-library/src/unittest.rs

+28-24
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
use super::signature::{
2-
canonicalize_uri_path, normalize_query_parameters, normalize_uri_path_component, sigv4_verify, Request,
3-
SignatureError, SigningKey, SigningKeyKind,
1+
use {
2+
super::signature::{
3+
canonicalize_uri_path, normalize_query_parameters, normalize_uri_path_component, sigv4_verify, Request,
4+
SignatureError, SigningKey, SigningKeyKind,
5+
},
6+
std::fmt::Write,
47
};
5-
use std::fmt::Write;
68

7-
use super::chronoutil::ParseISO8601;
8-
use chrono::{Date, DateTime, Datelike, NaiveDate, Timelike, Utc};
9-
use http::{
10-
header::{HeaderMap, HeaderValue},
11-
uri::{PathAndQuery, Uri},
9+
use {
10+
super::chronoutil::ParseISO8601,
11+
chrono::{Date, DateTime, Datelike, NaiveDate, Timelike, Utc},
12+
http::{
13+
header::{HeaderMap, HeaderValue},
14+
uri::{PathAndQuery, Uri},
15+
},
16+
scratchstack_aws_principal::PrincipalActor,
17+
test_log::{self, test},
18+
tokio,
1219
};
13-
use scratchstack_aws_principal::PrincipalActor;
14-
use test_log::{self, test};
15-
use tokio;
1620

1721
const TEST_REGION: &str = "us-east-1";
1822
const TEST_SERVICE: &str = "service";
@@ -191,8 +195,8 @@ fn duplicate_headers() {
191195
let uri = Uri::builder().path_and_query(PathAndQuery::from_static("/")).build().unwrap();
192196
let request = Request {
193197
request_method: "GET".to_string(),
194-
uri: uri,
195-
headers: headers,
198+
uri,
199+
headers,
196200
body: None,
197201
};
198202

@@ -244,8 +248,8 @@ async fn run_auth_test_get_err(auth_str: &str) -> SignatureError {
244248
let uri = Uri::builder().path_and_query(PathAndQuery::from_static("/")).build().unwrap();
245249
let request = Request {
246250
request_method: "GET".to_string(),
247-
uri: uri,
248-
headers: headers,
251+
uri,
252+
headers,
249253
body: None,
250254
};
251255

@@ -379,8 +383,8 @@ async fn test_multiple_algorithms() {
379383
let uri = Uri::builder().path_and_query(PathAndQuery::from_static("/")).build().unwrap();
380384
let request = Request {
381385
request_method: "GET".to_string(),
382-
uri: uri,
383-
headers: headers,
386+
uri,
387+
headers,
384388
body: None,
385389
};
386390

@@ -401,7 +405,7 @@ async fn duplicate_query_parameter() {
401405
.path_and_query(PathAndQuery::from_static("/?X-Amz-Signature=1234&X-Amz-Signature=1234"))
402406
.build()
403407
.unwrap(),
404-
headers: headers,
408+
headers,
405409
body: None,
406410
};
407411

@@ -418,7 +422,7 @@ fn missing_header() {
418422
let request = Request {
419423
request_method: "GET".to_string(),
420424
uri: Uri::builder().path_and_query(PathAndQuery::from_static("/")).build().unwrap(),
421-
headers: headers,
425+
headers,
422426
body: None,
423427
};
424428

@@ -435,7 +439,7 @@ fn missing_date() {
435439
let request = Request {
436440
request_method: "GET".to_string(),
437441
uri: Uri::builder().path_and_query(PathAndQuery::from_static("/")).build().unwrap(),
438-
headers: headers,
442+
headers,
439443
body: None,
440444
};
441445

@@ -453,7 +457,7 @@ fn invalid_date() {
453457
let request = Request {
454458
request_method: "GET".to_string(),
455459
uri: Uri::builder().path_and_query(PathAndQuery::from_static("/")).build().unwrap(),
456-
headers: headers,
460+
headers,
457461
body: None,
458462
};
459463

@@ -466,7 +470,7 @@ fn invalid_date() {
466470
let request = Request {
467471
request_method: "GET".to_string(),
468472
uri: Uri::builder().path_and_query(PathAndQuery::from_static("/")).build().unwrap(),
469-
headers: headers,
473+
headers,
470474
body: None,
471475
};
472476

@@ -476,7 +480,7 @@ fn invalid_date() {
476480
let request = Request {
477481
request_method: "GET".to_string(),
478482
uri: Uri::builder().path_and_query(PathAndQuery::from_static("/?X-Amz-Date=zzzz")).build().unwrap(),
479-
headers: headers,
483+
headers,
480484
body: None,
481485
};
482486

hyper-integration/src/lib.rs

+30-29
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,36 @@ pub use crate::service::AwsSigV4VerifierService;
33

44
#[cfg(test)]
55
mod tests {
6-
use crate::AwsSigV4VerifierService;
7-
use chrono::{Date, Utc};
8-
use futures::stream::StreamExt;
9-
use http::StatusCode;
10-
use hyper::{
11-
client::{connect::dns::GaiResolver, HttpConnector},
12-
server::conn::AddrStream,
13-
service::{make_service_fn, service_fn},
14-
Body, Request, Response, Server,
6+
use {
7+
crate::AwsSigV4VerifierService,
8+
chrono::{Date, Utc},
9+
futures::stream::StreamExt,
10+
http::StatusCode,
11+
hyper::{
12+
client::{connect::dns::GaiResolver, HttpConnector},
13+
server::conn::AddrStream,
14+
service::{make_service_fn, service_fn},
15+
Body, Request, Response, Server,
16+
},
17+
log::debug,
18+
rusoto_core::{DispatchSignedRequest, HttpClient, Region},
19+
rusoto_credential::AwsCredentials,
20+
rusoto_signature::SignedRequest,
21+
scratchstack_aws_principal::PrincipalActor,
22+
scratchstack_aws_signature::{
23+
get_signing_key_fn, GetSigningKeyRequest, SignatureError, SigningKey, SigningKeyKind,
24+
},
25+
std::{
26+
convert::Infallible,
27+
future::Future,
28+
net::{Ipv6Addr, SocketAddr, SocketAddrV6},
29+
pin::Pin,
30+
task::{Context, Poll},
31+
time::Duration,
32+
},
33+
test_env_log, tokio,
34+
tower::{BoxError, Service},
1535
};
16-
use log::debug;
17-
use rusoto_core::{DispatchSignedRequest, HttpClient, Region};
18-
use rusoto_credential::AwsCredentials;
19-
use rusoto_signature::SignedRequest;
20-
use scratchstack_aws_principal::PrincipalActor;
21-
use scratchstack_aws_signature::{
22-
get_signing_key_fn, GetSigningKeyRequest, SignatureError, SigningKey, SigningKeyKind,
23-
};
24-
use std::{
25-
convert::Infallible,
26-
future::Future,
27-
net::{Ipv6Addr, SocketAddr, SocketAddrV6},
28-
pin::Pin,
29-
task::{Context, Poll},
30-
time::Duration,
31-
};
32-
use test_env_log;
33-
use tokio;
34-
use tower::{BoxError, Service};
3536

3637
#[test_log::test(tokio::test)]
3738
async fn test_fn_wrapper() {
@@ -210,7 +211,7 @@ mod tests {
210211
Ok((principal, k_secret.derive(signing_key_kind, &request_date, region, service)))
211212
} else {
212213
Err(SignatureError::UnknownAccessKey {
213-
access_key: access_key,
214+
access_key,
214215
}
215216
.into())
216217
}

hyper-integration/src/service.rs

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
use chrono::Duration;
2-
use futures::stream::StreamExt;
3-
use http::request::Parts;
4-
use hyper::{
5-
body::{Body, Bytes},
6-
Error as HyperError, Request, Response,
1+
use {
2+
chrono::Duration,
3+
futures::stream::StreamExt,
4+
http::request::Parts,
5+
hyper::{
6+
body::{Body, Bytes},
7+
Error as HyperError, Request, Response,
8+
},
9+
log::{debug, warn},
10+
scratchstack_aws_principal::PrincipalActor,
11+
scratchstack_aws_signature::{
12+
sigv4_verify, GetSigningKeyRequest, Request as AwsSigVerifyRequest, SigningKey, SigningKeyKind,
13+
},
14+
std::{
15+
any::type_name,
16+
fmt::{Debug, Display, Formatter, Result as FmtResult},
17+
future::Future,
18+
pin::Pin,
19+
task::{Context, Poll},
20+
},
21+
tower::{buffer::Buffer, BoxError, Service, ServiceExt},
722
};
8-
use log::{debug, warn};
9-
use scratchstack_aws_principal::PrincipalActor;
10-
use scratchstack_aws_signature::{
11-
sigv4_verify, GetSigningKeyRequest, Request as AwsSigVerifyRequest, SigningKey, SigningKeyKind,
12-
};
13-
use std::{
14-
any::type_name,
15-
fmt::{Debug, Display, Formatter, Result as FmtResult},
16-
future::Future,
17-
pin::Pin,
18-
task::{Context, Poll},
19-
};
20-
use tower::{buffer::Buffer, BoxError, Service, ServiceExt};
2123

2224
/// AWSSigV4VerifierService implements a Hyper service that authenticates a request against AWS SigV4 signing protocol.
2325
#[derive(Clone)]

rustfmt.toml

+13
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1+
edition = "2021"
2+
force_explicit_abi = true
3+
fn_params_layout = "Tall"
4+
hard_tabs = false
5+
imports_granularity = "One"
16
max_width = 120
7+
merge_derives = true
8+
newline_style = "Auto"
9+
remove_nested_parens = true
10+
reorder_imports = true
11+
reorder_modules = true
12+
tab_spaces = 4
13+
use_field_init_shorthand = true
214
use_small_heuristics = "Off"
15+
use_try_shorthand = true

0 commit comments

Comments
 (0)