Skip to content

Commit ce3488f

Browse files
committed
Fixed 'mithril-client' clippy warnings from Rust 1.67.0
1 parent 364cab5 commit ce3488f

File tree

7 files changed

+29
-38
lines changed

7 files changed

+29
-38
lines changed

mithril-client/src/aggregator.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ impl AggregatorHTTPClient {
155155
))
156156
} else {
157157
AggregatorHandlerError::ApiVersionMismatch(format!(
158-
"version precondition failed, sent version '{}'.",
159-
MITHRIL_API_VERSION
158+
"version precondition failed, sent version '{MITHRIL_API_VERSION}'."
160159
))
161160
}
162161
}
@@ -314,8 +313,7 @@ impl CertificateRetriever for AggregatorHTTPClient {
314313
/// Computes local archive filepath
315314
fn archive_file_path(digest: &str, network: &str) -> Result<PathBuf, AggregatorHandlerError> {
316315
Ok(env::current_dir()?.join(path::Path::new(&format!(
317-
"data/{}/{}/snapshot.archive.tar.gz",
318-
network, digest
316+
"data/{network}/{digest}/snapshot.archive.tar.gz"
319317
))))
320318
}
321319

@@ -362,7 +360,7 @@ mod tests {
362360
.join(path::Path::new(data_file_name));
363361
fs::create_dir_all(source_file_path.parent().unwrap()).unwrap();
364362
let mut source_file = fs::File::create(&source_file_path).unwrap();
365-
write!(source_file, "{}", data_expected).unwrap();
363+
write!(source_file, "{data_expected}").unwrap();
366364
let archive_file = fs::File::create(&archive_file_path).unwrap();
367365
let archive_encoder = GzEncoder::new(&archive_file, Compression::default());
368366
let mut archive_builder = tar::Builder::new(archive_encoder);
@@ -428,7 +426,7 @@ mod tests {
428426
let (server, config) = setup_test();
429427
let snapshot_expected = fake_data::snapshots(1).first().unwrap().to_owned();
430428
let _snapshots_mock = server.mock(|when, then| {
431-
when.path(format!("/snapshot/{}", digest));
429+
when.path(format!("/snapshot/{digest}"));
432430
then.status(200).body(json!(snapshot_expected).to_string());
433431
});
434432
let aggregator_client =
@@ -443,7 +441,7 @@ mod tests {
443441
let digest = "digest123";
444442
let (server, config) = setup_test();
445443
let _snapshots_mock = server.mock(|when, then| {
446-
when.path(format!("/snapshot/{}", digest));
444+
when.path(format!("/snapshot/{digest}"));
447445
then.status(404);
448446
});
449447
let aggregator_client =
@@ -457,7 +455,7 @@ mod tests {
457455
let (server, config) = setup_test();
458456
let digest = "digest123";
459457
let _snapshots_mock = server.mock(|when, then| {
460-
when.path(format!("/snapshot/{}", digest));
458+
when.path(format!("/snapshot/{digest}"));
461459
then.status(412).header("mithril-api-version", "0.0.999");
462460
});
463461
let aggregator_client =
@@ -475,7 +473,7 @@ mod tests {
475473
let digest = "digest123";
476474
let (server, config) = setup_test();
477475
let _snapshots_mock = server.mock(|when, then| {
478-
when.path(format!("/snapshot/{}", digest));
476+
when.path(format!("/snapshot/{digest}"));
479477
then.status(500);
480478
});
481479
let aggregator_client =
@@ -594,7 +592,7 @@ mod tests {
594592
let (server, config) = setup_test();
595593
let certificate_hash = "certificate-hash-123";
596594
let _snapshots_mock = server.mock(|when, then| {
597-
when.path(format!("/certificate/{}", certificate_hash));
595+
when.path(format!("/certificate/{certificate_hash}"));
598596
then.status(412).header("mithril-api-version", "0.0.999");
599597
});
600598
let aggregator_client =
@@ -611,7 +609,7 @@ mod tests {
611609
let (server, config) = setup_test();
612610
let certificate_expected = fake_data::certificate(certificate_hash.to_string());
613611
let _certificate_mock = server.mock(|when, then| {
614-
when.path(format!("/certificate/{}", certificate_hash));
612+
when.path(format!("/certificate/{certificate_hash}"));
615613
then.status(200)
616614
.body(json!(certificate_expected).to_string());
617615
});
@@ -629,7 +627,7 @@ mod tests {
629627
let certificate_hash = "certificate-hash-123";
630628
let (server, config) = setup_test();
631629
let _certificate_mock = server.mock(|when, then| {
632-
when.path(format!("/certificate/{}", certificate_hash));
630+
when.path(format!("/certificate/{certificate_hash}"));
633631
then.status(404);
634632
});
635633
let aggregator_client =
@@ -645,7 +643,7 @@ mod tests {
645643
let certificate_hash = "certificate-hash-123";
646644
let (server, config) = setup_test();
647645
let _certificate_mock = server.mock(|when, then| {
648-
when.path(format!("/certificate/{}", certificate_hash));
646+
when.path(format!("/certificate/{certificate_hash}"));
649647
then.status(500);
650648
});
651649
let aggregator_client =

mithril-client/src/commands/download.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ impl DownloadCommand {
3131
debug!("Download snapshots");
3232
let config: Config = config_builder
3333
.build()
34-
.map_err(|e| format!("configuration build error: {}", e))?
34+
.map_err(|e| format!("configuration build error: {e}"))?
3535
.try_deserialize()
36-
.map_err(|e| format!("configuration deserialize error: {}", e))?;
36+
.map_err(|e| format!("configuration deserialize error: {e}"))?;
3737
debug!("{:?}", config);
3838
let runtime = Runtime::new(config.network.clone());
3939
let aggregator_handler =
@@ -50,9 +50,9 @@ impl DownloadCommand {
5050
let output = if self.json {
5151
serde_json::to_string(&token)?
5252
} else {
53-
format!("success!\n{}", token)
53+
format!("success!\n{token}")
5454
};
55-
println!("{}", output);
55+
println!("{output}");
5656
Ok(())
5757
}
5858
}

mithril-client/src/commands/list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ impl ListCommand {
2424
debug!("List snapshots");
2525
let config: Config = config_builder
2626
.build()
27-
.map_err(|e| format!("configuration build error: {}", e))?
27+
.map_err(|e| format!("configuration build error: {e}"))?
2828
.try_deserialize()
29-
.map_err(|e| format!("configuration deserialize error: {}", e))?;
29+
.map_err(|e| format!("configuration deserialize error: {e}"))?;
3030
debug!("{:?}", config);
3131
let runtime = Runtime::new(config.network.clone());
3232
let aggregator_handler =

mithril-client/src/commands/restore.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ impl RestoreCommand {
4444
debug!("Restore snapshot");
4545
let config: Config = config_builder
4646
.build()
47-
.map_err(|e| format!("configuration build error: {}", e))?
47+
.map_err(|e| format!("configuration build error: {e}"))?
4848
.try_deserialize()
49-
.map_err(|e| format!("configuration deserialize error: {}", e))?;
49+
.map_err(|e| format!("configuration deserialize error: {e}"))?;
5050
debug!("{:?}", config);
5151
let mut runtime = Runtime::new(config.network.clone());
5252
let aggregator_handler =

mithril-client/src/commands/show.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ impl ShowCommand {
2727
debug!("Show snapshot");
2828
let config: Config = config_builder
2929
.build()
30-
.map_err(|e| format!("configuration build error: {}", e))?
30+
.map_err(|e| format!("configuration build error: {e}"))?
3131
.try_deserialize()
32-
.map_err(|e| format!("configuration deserialize error: {}", e))?;
32+
.map_err(|e| format!("configuration deserialize error: {e}"))?;
3333
debug!("{:?}", config);
3434
let runtime = Runtime::new(config.network.clone());
3535
let aggregator_handler =

mithril-client/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,5 @@ async fn main() -> Result<(), String> {
140140

141141
args.execute()
142142
.await
143-
.map_err(|e| format!("An error occured: {:?}", e))
143+
.map_err(|e| format!("An error occured: {e:?}"))
144144
}

mithril-client/src/runtime.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,7 @@ mod tests {
339339
.await;
340340
assert!(
341341
matches!(snapshot_list_items, Err(RuntimeError::AggregatorHandler(_))),
342-
"unexpected error type: {:?}",
343-
snapshot_list_items
342+
"unexpected error type: {snapshot_list_items:?}"
344343
);
345344
}
346345

@@ -380,8 +379,7 @@ mod tests {
380379
.await;
381380
assert!(
382381
matches!(snapshot_item, Err(RuntimeError::AggregatorHandler(_))),
383-
"unexpected error type: {:?}",
384-
snapshot_item
382+
"unexpected error type: {snapshot_item:?}"
385383
);
386384
}
387385

@@ -474,8 +472,7 @@ mod tests {
474472
.await;
475473
assert!(
476474
matches!(restore, Err(RuntimeError::Protocol(_))),
477-
"unexpected error type: {:?}",
478-
restore
475+
"unexpected error type: {restore:?}"
479476
);
480477
}
481478

@@ -520,8 +517,7 @@ mod tests {
520517
.await;
521518
assert!(
522519
matches!(restore, Err(RuntimeError::ImmutableDigester(_))),
523-
"unexpected error type: {:?}",
524-
restore
520+
"unexpected error type: {restore:?}"
525521
);
526522
}
527523

@@ -550,8 +546,7 @@ mod tests {
550546
.await;
551547
assert!(
552548
matches!(restore, Err(RuntimeError::AggregatorHandler(_))),
553-
"unexpected error type: {:?}",
554-
restore
549+
"unexpected error type: {restore:?}"
555550
);
556551
}
557552

@@ -585,8 +580,7 @@ mod tests {
585580
.await;
586581
assert!(
587582
matches!(restore, Err(RuntimeError::CertificateRetriever(_))),
588-
"unexpected error type: {:?}",
589-
restore
583+
"unexpected error type: {restore:?}"
590584
);
591585
}
592586

@@ -626,8 +620,7 @@ mod tests {
626620
.await;
627621
assert!(
628622
matches!(restore, Err(RuntimeError::AggregatorHandler(_))),
629-
"unexpected error type: {:?}",
630-
restore
623+
"unexpected error type: {restore:?}"
631624
);
632625
}
633626
}

0 commit comments

Comments
 (0)