Skip to content

Commit c60075f

Browse files
committed
remove needless mut
1 parent 1178c25 commit c60075f

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

src/client.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl Client {
289289
/// The client will check if it's already been authenticated and if
290290
/// not will attempt to do.
291291
pub async fn list_tags(
292-
&mut self,
292+
&self,
293293
image: &Reference,
294294
auth: &RegistryAuth,
295295
n: Option<usize>,
@@ -336,7 +336,7 @@ impl Client {
336336
/// The client will check if it's already been authenticated and if
337337
/// not will attempt to do.
338338
pub async fn pull(
339-
&mut self,
339+
&self,
340340
image: &Reference,
341341
auth: &RegistryAuth,
342342
accepted_media_types: Vec<&str>,
@@ -354,7 +354,7 @@ impl Client {
354354

355355
let layers = stream::iter(&manifest.layers)
356356
.map(|layer| {
357-
// This avoids moving `self` which is &mut Self
357+
// This avoids moving `self` which is &Self
358358
// into the async block. We only want to capture
359359
// as &Self
360360
let this = &self;
@@ -392,7 +392,7 @@ impl Client {
392392
///
393393
/// Returns pullable URL for the image
394394
pub async fn push(
395-
&mut self,
395+
&self,
396396
image_ref: &Reference,
397397
layers: &[ImageLayer],
398398
config: Config,
@@ -413,7 +413,7 @@ impl Client {
413413
// Upload layers
414414
stream::iter(layers)
415415
.map(|layer| {
416-
// This avoids moving `self` which is &mut Self
416+
// This avoids moving `self` which is &Self
417417
// into the async block. We only want to capture
418418
// as &Self
419419
let this = &self;
@@ -497,7 +497,7 @@ impl Client {
497497
/// This performs authorization and then stores the token internally to be used
498498
/// on other requests.
499499
pub async fn auth(
500-
&mut self,
500+
&self,
501501
image: &Reference,
502502
authentication: &RegistryAuth,
503503
operation: RegistryOperation,
@@ -589,7 +589,7 @@ impl Client {
589589
/// HEAD request. If this header is not present, will make a second GET
590590
/// request and return the SHA256 of the response body.
591591
pub async fn fetch_manifest_digest(
592-
&mut self,
592+
&self,
593593
image: &Reference,
594594
auth: &RegistryAuth,
595595
) -> Result<String> {
@@ -666,7 +666,7 @@ impl Client {
666666
/// If a multi-platform Image Index manifest is encountered, a platform-specific
667667
/// Image manifest will be selected using the client's default platform resolution.
668668
pub async fn pull_image_manifest(
669-
&mut self,
669+
&self,
670670
image: &Reference,
671671
auth: &RegistryAuth,
672672
) -> Result<(OciImageManifest, String)> {
@@ -686,7 +686,7 @@ impl Client {
686686
/// A Tuple is returned containing the [Manifest](crate::manifest::OciImageManifest)
687687
/// and the manifest content digest hash.
688688
pub async fn pull_manifest(
689-
&mut self,
689+
&self,
690690
image: &Reference,
691691
auth: &RegistryAuth,
692692
) -> Result<(OciManifest, String)> {
@@ -807,7 +807,7 @@ impl Client {
807807
/// the manifest content digest hash and the contents of the manifests config layer
808808
/// as a String.
809809
pub async fn pull_manifest_and_config(
810-
&mut self,
810+
&self,
811811
image: &Reference,
812812
auth: &RegistryAuth,
813813
) -> Result<(OciImageManifest, String, String)> {
@@ -833,7 +833,7 @@ impl Client {
833833
}
834834

835835
async fn _pull_manifest_and_config(
836-
&mut self,
836+
&self,
837837
image: &Reference,
838838
) -> Result<(OciImageManifest, String, Config)> {
839839
let (manifest, digest) = self._pull_image_manifest(image).await?;
@@ -851,7 +851,7 @@ impl Client {
851851
///
852852
/// This pushes a manifest list to an OCI registry.
853853
pub async fn push_manifest_list(
854-
&mut self,
854+
&self,
855855
reference: &Reference,
856856
auth: &RegistryAuth,
857857
manifest: OciImageIndex,
@@ -1740,7 +1740,7 @@ mod test {
17401740
use hmac::{Hmac, Mac};
17411741
use jwt::SignWithKey;
17421742
use sha2::Sha256;
1743-
let mut client = Client::default();
1743+
let client = Client::default();
17441744
let header = jwt::header::Header {
17451745
algorithm: jwt::algorithm::AlgorithmType::Hs256,
17461746
key_id: None,
@@ -2052,7 +2052,7 @@ mod test {
20522052
async fn test_auth() {
20532053
for &image in TEST_IMAGES {
20542054
let reference = Reference::try_from(image).expect("failed to parse reference");
2055-
let mut c = Client::default();
2055+
let c = Client::default();
20562056
let token = c
20572057
.auth(
20582058
&reference,
@@ -2088,7 +2088,7 @@ mod test {
20882088
let auth =
20892089
RegistryAuth::Basic(HTPASSWD_USERNAME.to_string(), HTPASSWD_PASSWORD.to_string());
20902090

2091-
let mut client = Client::new(ClientConfig {
2091+
let client = Client::new(ClientConfig {
20922092
protocol: ClientProtocol::HttpsExcept(vec![format!("localhost:{}", port)]),
20932093
..Default::default()
20942094
});
@@ -2150,7 +2150,7 @@ mod test {
21502150
.expect_err("pull manifest should fail");
21512151

21522152
// But this should pass
2153-
let mut c = Client::default();
2153+
let c = Client::default();
21542154
c.auth(
21552155
&reference,
21562156
&RegistryAuth::Anonymous,
@@ -2173,7 +2173,7 @@ mod test {
21732173
async fn test_pull_manifest_public() {
21742174
for &image in TEST_IMAGES {
21752175
let reference = Reference::try_from(image).expect("failed to parse reference");
2176-
let mut c = Client::default();
2176+
let c = Client::default();
21772177
let (manifest, _) = c
21782178
.pull_image_manifest(&reference, &RegistryAuth::Anonymous)
21792179
.await
@@ -2189,7 +2189,7 @@ mod test {
21892189
async fn pull_manifest_and_config_public() {
21902190
for &image in TEST_IMAGES {
21912191
let reference = Reference::try_from(image).expect("failed to parse reference");
2192-
let mut c = Client::default();
2192+
let c = Client::default();
21932193
let (manifest, _, config) = c
21942194
.pull_manifest_and_config(&reference, &RegistryAuth::Anonymous)
21952195
.await
@@ -2204,7 +2204,7 @@ mod test {
22042204

22052205
#[tokio::test]
22062206
async fn test_fetch_digest() {
2207-
let mut c = Client::default();
2207+
let c = Client::default();
22082208

22092209
for &image in TEST_IMAGES {
22102210
let reference = Reference::try_from(image).expect("failed to parse reference");
@@ -2214,7 +2214,7 @@ mod test {
22142214

22152215
// This should pass
22162216
let reference = Reference::try_from(image).expect("failed to parse reference");
2217-
let mut c = Client::default();
2217+
let c = Client::default();
22182218
c.auth(
22192219
&reference,
22202220
&RegistryAuth::Anonymous,
@@ -2236,7 +2236,7 @@ mod test {
22362236

22372237
#[tokio::test]
22382238
async fn test_pull_blob() {
2239-
let mut c = Client::default();
2239+
let c = Client::default();
22402240

22412241
for &image in TEST_IMAGES {
22422242
let reference = Reference::try_from(image).expect("failed to parse reference");
@@ -2283,7 +2283,7 @@ mod test {
22832283

22842284
#[tokio::test]
22852285
async fn test_pull_blob_stream() {
2286-
let mut c = Client::default();
2286+
let c = Client::default();
22872287

22882288
for &image in TEST_IMAGES {
22892289
let reference = Reference::try_from(image).expect("failed to parse reference");
@@ -2419,7 +2419,7 @@ mod test {
24192419
let test_container = docker.run(registry_image());
24202420
let port = test_container.get_host_port_ipv4(5000);
24212421

2422-
let mut c = Client::new(ClientConfig {
2422+
let c = Client::new(ClientConfig {
24232423
protocol: ClientProtocol::Http,
24242424
..Default::default()
24252425
});
@@ -2534,7 +2534,7 @@ mod test {
25342534
let _ = tracing_subscriber::fmt::try_init();
25352535
let port = test_container.get_host_port_ipv4(5000);
25362536

2537-
let mut c = Client::new(ClientConfig {
2537+
let c = Client::new(ClientConfig {
25382538
protocol: ClientProtocol::HttpsExcept(vec![format!("localhost:{}", port)]),
25392539
..Default::default()
25402540
});
@@ -2641,7 +2641,7 @@ mod test {
26412641
async fn test_platform_resolution() {
26422642
// test that we get an error when we pull a manifest list
26432643
let reference = Reference::try_from(DOCKER_IO_IMAGE).expect("failed to parse reference");
2644-
let mut c = Client::new(ClientConfig {
2644+
let c = Client::new(ClientConfig {
26452645
platform_resolver: None,
26462646
..Default::default()
26472647
});
@@ -2671,7 +2671,7 @@ mod test {
26712671
#[tokio::test]
26722672
async fn test_pull_ghcr_io() {
26732673
let reference = Reference::try_from(GHCR_IO_IMAGE).expect("failed to parse reference");
2674-
let mut c = Client::default();
2674+
let c = Client::default();
26752675
let (manifest, _manifest_str) = c
26762676
.pull_image_manifest(&reference, &RegistryAuth::Anonymous)
26772677
.await
@@ -2683,7 +2683,7 @@ mod test {
26832683
#[ignore]
26842684
async fn test_roundtrip_multiple_layers() {
26852685
let _ = tracing_subscriber::fmt::try_init();
2686-
let mut c = Client::new(ClientConfig {
2686+
let c = Client::new(ClientConfig {
26872687
protocol: ClientProtocol::HttpsExcept(vec!["oci.registry.local".to_string()]),
26882688
..Default::default()
26892689
});

src/token_cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl TokenCache {
7575
}
7676

7777
pub(crate) async fn insert(
78-
&mut self,
78+
&self,
7979
reference: &Reference,
8080
op: RegistryOperation,
8181
token: RegistryTokenType,

0 commit comments

Comments
 (0)