Skip to content

Commit 3a0612f

Browse files
allisonkarlitskayacgwalters
authored andcommitted
imageproxy: drop generic parameters from impl_request()
These can be expressed with `impl Trait` argument syntax, making things a bit easier to read. Signed-off-by: Allison Karlitskaya <[email protected]> Signed-off-by: Colin Walters <[email protected]>
1 parent c2b29ce commit 3a0612f

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/imageproxy.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl ImageProxy {
426426
};
427427

428428
// Verify semantic version
429-
let protover = r.impl_request::<String, _, ()>("Initialize", []).await?.0;
429+
let protover = r.impl_request::<String>("Initialize", [(); 0]).await?.0;
430430
tracing::debug!("Remote protocol version: {protover}");
431431
let protover = semver::Version::parse(protover.as_str())?;
432432
// Previously we had a feature to opt-in to requiring newer versions using `if cfg!()`.
@@ -494,15 +494,11 @@ impl ImageProxy {
494494
}
495495

496496
#[instrument(skip(args))]
497-
async fn impl_request<R: serde::de::DeserializeOwned + Send + 'static, T, I>(
497+
async fn impl_request<R: serde::de::DeserializeOwned + Send + 'static>(
498498
&self,
499499
method: &str,
500-
args: T,
501-
) -> Result<(R, Option<FileDescriptors>)>
502-
where
503-
T: IntoIterator<Item = I>,
504-
I: Into<serde_json::Value>,
505-
{
500+
args: impl IntoIterator<Item = impl Into<serde_json::Value>>,
501+
) -> Result<(R, Option<FileDescriptors>)> {
506502
let req = Self::impl_request_raw(Arc::clone(&self.sockfd), Request::new(method, args));
507503
let mut childwait = self.childwait.lock().await;
508504
tokio::select! {
@@ -529,7 +525,7 @@ impl ImageProxy {
529525
pub async fn open_image(&self, imgref: &str) -> Result<OpenedImage> {
530526
tracing::debug!("opening image");
531527
let (imgid, _) = self
532-
.impl_request::<u32, _, _>("OpenImage", [imgref])
528+
.impl_request::<u32>("OpenImage", [imgref])
533529
.await?;
534530
Ok(OpenedImage(imgid))
535531
}
@@ -538,7 +534,7 @@ impl ImageProxy {
538534
pub async fn open_image_optional(&self, imgref: &str) -> Result<Option<OpenedImage>> {
539535
tracing::debug!("opening image");
540536
let (imgid, _) = self
541-
.impl_request::<u32, _, _>("OpenImageOptional", [imgref])
537+
.impl_request::<u32>("OpenImageOptional", [imgref])
542538
.await?;
543539
if imgid == 0 {
544540
Ok(None)
@@ -592,7 +588,7 @@ impl ImageProxy {
592588
/// For more information on OCI config, see <https://github.com/opencontainers/image-spec/blob/main/config.md>
593589
pub async fn fetch_config_raw(&self, img: &OpenedImage) -> Result<Vec<u8>> {
594590
let (_, fd) = self
595-
.impl_request::<(), _, _>("GetFullConfig", [img.0])
591+
.impl_request::<()>("GetFullConfig", [img.0])
596592
.await?;
597593
self.read_all_fd(fd).await
598594
}
@@ -631,7 +627,7 @@ impl ImageProxy {
631627
tracing::debug!("fetching blob");
632628
let args: Vec<serde_json::Value> =
633629
vec![img.0.into(), digest.to_string().into(), size.into()];
634-
let (_bloblen, fd) = self.impl_request::<i64, _, _>("GetBlob", args).await?;
630+
let (_bloblen, fd) = self.impl_request::<i64>("GetBlob", args).await?;
635631
let fd = fd.ok_or_else(|| Error::Other("Missing fd from reply".into()))?;
636632
let FileDescriptors::FinishPipe { pipeid, datafd } = fd else {
637633
return Err(Error::Other("got dualfds, expecting FinishPipe fd".into()));
@@ -683,7 +679,7 @@ impl ImageProxy {
683679
)> {
684680
tracing::debug!("fetching blob");
685681
let args: Vec<serde_json::Value> = vec![img.0.into(), digest.to_string().into()];
686-
let (bloblen, fd) = self.impl_request::<u64, _, _>("GetRawBlob", args).await?;
682+
let (bloblen, fd) = self.impl_request::<u64>("GetRawBlob", args).await?;
687683
let fd = fd.ok_or_else(|| Error::new_other("Missing fd from reply"))?;
688684
let FileDescriptors::DualFds { datafd, errfd } = fd else {
689685
return Err(Error::Other("got single fd, expecting dual fds".into()));
@@ -716,7 +712,7 @@ impl ImageProxy {
716712
tracing::debug!("Getting layer info");
717713
if layer_info_piped_proto_version().matches(&self.protover) {
718714
let (_, fd) = self
719-
.impl_request::<(), _, _>("GetLayerInfoPiped", [img.0])
715+
.impl_request::<()>("GetLayerInfoPiped", [img.0])
720716
.await?;
721717
let buf = self.read_all_fd(fd).await?;
722718
return Ok(Some(serde_json::from_slice(&buf)?));

0 commit comments

Comments
 (0)