Skip to content

Commit fd2a982

Browse files
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]>
1 parent 08dd85d commit fd2a982

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!()`.
@@ -493,15 +493,11 @@ impl ImageProxy {
493493
}
494494

495495
#[instrument(skip(args))]
496-
async fn impl_request<R: serde::de::DeserializeOwned + Send + 'static, T, I>(
496+
async fn impl_request<R: serde::de::DeserializeOwned + Send + 'static>(
497497
&self,
498498
method: &str,
499-
args: T,
500-
) -> Result<(R, Option<FileDescriptors>)>
501-
where
502-
T: IntoIterator<Item = I>,
503-
I: Into<serde_json::Value>,
504-
{
499+
args: impl IntoIterator<Item = impl Into<serde_json::Value>>,
500+
) -> Result<(R, Option<FileDescriptors>)> {
505501
let req = Self::impl_request_raw(Arc::clone(&self.sockfd), Request::new(method, args));
506502
let mut childwait = self.childwait.lock().await;
507503
tokio::select! {
@@ -528,7 +524,7 @@ impl ImageProxy {
528524
pub async fn open_image(&self, imgref: &str) -> Result<OpenedImage> {
529525
tracing::debug!("opening image");
530526
let (imgid, _) = self
531-
.impl_request::<u32, _, _>("OpenImage", [imgref])
527+
.impl_request::<u32>("OpenImage", [imgref])
532528
.await?;
533529
Ok(OpenedImage(imgid))
534530
}
@@ -537,7 +533,7 @@ impl ImageProxy {
537533
pub async fn open_image_optional(&self, imgref: &str) -> Result<Option<OpenedImage>> {
538534
tracing::debug!("opening image");
539535
let (imgid, _) = self
540-
.impl_request::<u32, _, _>("OpenImageOptional", [imgref])
536+
.impl_request::<u32>("OpenImageOptional", [imgref])
541537
.await?;
542538
if imgid == 0 {
543539
Ok(None)
@@ -591,7 +587,7 @@ impl ImageProxy {
591587
/// For more information on OCI config, see <https://github.com/opencontainers/image-spec/blob/main/config.md>
592588
pub async fn fetch_config_raw(&self, img: &OpenedImage) -> Result<Vec<u8>> {
593589
let (_, fd) = self
594-
.impl_request::<(), _, _>("GetFullConfig", [img.0])
590+
.impl_request::<()>("GetFullConfig", [img.0])
595591
.await?;
596592
self.read_all_fd(fd).await
597593
}
@@ -630,7 +626,7 @@ impl ImageProxy {
630626
tracing::debug!("fetching blob");
631627
let args: Vec<serde_json::Value> =
632628
vec![img.0.into(), digest.to_string().into(), size.into()];
633-
let (_bloblen, fd) = self.impl_request::<i64, _, _>("GetBlob", args).await?;
629+
let (_bloblen, fd) = self.impl_request::<i64>("GetBlob", args).await?;
634630
let fd = fd.ok_or_else(|| Error::Other("Missing fd from reply".into()))?;
635631
let FileDescriptors::FinishPipe { pipeid, datafd } = fd else {
636632
return Err(Error::Other("got dualfds, expecting FinishPipe fd".into()));
@@ -682,7 +678,7 @@ impl ImageProxy {
682678
)> {
683679
tracing::debug!("fetching blob");
684680
let args: Vec<serde_json::Value> = vec![img.0.into(), digest.to_string().into()];
685-
let (bloblen, fd) = self.impl_request::<u64, _, _>("GetRawBlob", args).await?;
681+
let (bloblen, fd) = self.impl_request::<u64>("GetRawBlob", args).await?;
686682
let fd = fd.ok_or_else(|| Error::new_other("Missing fd from reply"))?;
687683
let FileDescriptors::DualFds { datafd, errfd } = fd else {
688684
return Err(Error::Other("got single fd, expecting dual fds".into()));
@@ -715,7 +711,7 @@ impl ImageProxy {
715711
tracing::debug!("Getting layer info");
716712
if layer_info_piped_proto_version().matches(&self.protover) {
717713
let (_, fd) = self
718-
.impl_request::<(), _, _>("GetLayerInfoPiped", [img.0])
714+
.impl_request::<()>("GetLayerInfoPiped", [img.0])
719715
.await?;
720716
let buf = self.read_all_fd(fd).await?;
721717
return Ok(Some(serde_json::from_slice(&buf)?));

0 commit comments

Comments
 (0)