@@ -26,31 +26,37 @@ fn main() {
2626 if options. output_format == OutputFormat :: StdOut {
2727 println ! ( "Starting Cloudflare speed test" ) ;
2828 }
29-
29+
3030 let client = match build_http_client ( & options) {
3131 Ok ( client) => client,
3232 Err ( e) => {
3333 eprintln ! ( "Error: {}" , e) ;
3434 std:: process:: exit ( 1 ) ;
3535 }
3636 } ;
37-
37+
3838 speed_test ( client, options) ;
3939}
4040
4141fn build_http_client ( options : & SpeedTestCLIOptions ) -> Result < reqwest:: blocking:: Client , String > {
42- let mut builder = reqwest :: blocking :: Client :: builder ( )
43- . timeout ( std:: time:: Duration :: from_secs ( 30 ) ) ;
44-
42+ let mut builder =
43+ reqwest :: blocking :: Client :: builder ( ) . timeout ( std:: time:: Duration :: from_secs ( 30 ) ) ;
44+
4545 if let Some ( ref ip) = options. ipv4 {
46- let ip_addr = ip. parse :: < IpAddr > ( ) . map_err ( |e| format ! ( "Invalid IPv4 address '{}': {}" , ip, e) ) ?;
46+ let ip_addr = ip
47+ . parse :: < IpAddr > ( )
48+ . map_err ( |e| format ! ( "Invalid IPv4 address '{}': {}" , ip, e) ) ?;
4749 builder = builder. local_address ( ip_addr) ;
4850 } else if let Some ( ref ip) = options. ipv6 {
49- let ip_addr = ip. parse :: < IpAddr > ( ) . map_err ( |e| format ! ( "Invalid IPv6 address '{}': {}" , ip, e) ) ?;
51+ let ip_addr = ip
52+ . parse :: < IpAddr > ( )
53+ . map_err ( |e| format ! ( "Invalid IPv6 address '{}': {}" , ip, e) ) ?;
5054 builder = builder. local_address ( ip_addr) ;
5155 }
52-
53- builder. build ( ) . map_err ( |e| format ! ( "Failed to initialize HTTP client: {}" , e) )
56+
57+ builder
58+ . build ( )
59+ . map_err ( |e| format ! ( "Failed to initialize HTTP client: {}" , e) )
5460}
5561
5662#[ cfg( test) ]
@@ -64,7 +70,7 @@ mod tests {
6470 ipv6 : None ,
6571 ..Default :: default ( )
6672 } ;
67-
73+
6874 let result = build_http_client ( & options) ;
6975 assert ! ( result. is_err( ) ) ;
7076 let err = result. unwrap_err ( ) ;
@@ -79,7 +85,7 @@ mod tests {
7985 ipv6 : Some ( "invalid-ipv6" . to_string ( ) ) ,
8086 ..Default :: default ( )
8187 } ;
82-
88+
8389 let result = build_http_client ( & options) ;
8490 assert ! ( result. is_err( ) ) ;
8591 let err = result. unwrap_err ( ) ;
@@ -94,7 +100,7 @@ mod tests {
94100 ipv6 : None ,
95101 ..Default :: default ( )
96102 } ;
97-
103+
98104 let result = build_http_client ( & options) ;
99105 assert ! ( result. is_ok( ) ) ;
100106 }
@@ -106,7 +112,7 @@ mod tests {
106112 ipv6 : Some ( "::1" . to_string ( ) ) ,
107113 ..Default :: default ( )
108114 } ;
109-
115+
110116 let result = build_http_client ( & options) ;
111117 assert ! ( result. is_ok( ) ) ;
112118 }
@@ -118,7 +124,7 @@ mod tests {
118124 ipv6 : None ,
119125 ..Default :: default ( )
120126 } ;
121-
127+
122128 let result = build_http_client ( & options) ;
123129 assert ! ( result. is_ok( ) ) ;
124130 }
0 commit comments