diff --git a/Cargo.toml b/Cargo.toml index f64f837..36f3451 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,3 +24,7 @@ tracing = "0.1" [lib] path = "src/imageproxy.rs" + +[features] +# See https://github.com/containers/skopeo/blob/03da797e42374892bca8759668adb0b06d087876/cmd/skopeo/proxy.go#L95 +proxy_v0_2_4 = [] diff --git a/src/imageproxy.rs b/src/imageproxy.rs index eb6104e..e7a1b68 100644 --- a/src/imageproxy.rs +++ b/src/imageproxy.rs @@ -333,6 +333,20 @@ impl ImageProxy { Ok(OpenedImage(imgid)) } + #[instrument] + #[cfg(feature = "proxy_v0_2_4")] + pub async fn open_image_optional(&self, imgref: &str) -> Result> { + tracing::debug!("opening image"); + let (imgid, _) = self + .impl_request::("OpenImageOptional", [imgref]) + .await?; + if imgid == 0 { + Ok(None) + } else { + Ok(Some(OpenedImage(imgid))) + } + } + #[instrument] pub async fn close_image(&self, img: &OpenedImage) -> Result<()> { tracing::debug!("closing image");