Skip to content

Commit 9653eaa

Browse files
committed
Add support for proxy semver 0.2.4 API
Specifically this binds `OpenImageOptional`. Signed-off-by: Colin Walters <[email protected]>
1 parent a4223a0 commit 9653eaa

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ tracing = "0.1"
2424

2525
[lib]
2626
path = "src/imageproxy.rs"
27+
28+
[features]
29+
# See https://github.com/containers/skopeo/blob/03da797e42374892bca8759668adb0b06d087876/cmd/skopeo/proxy.go#L95
30+
proxy_v0_2_4 = []

src/imageproxy.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,20 @@ impl ImageProxy {
333333
Ok(OpenedImage(imgid))
334334
}
335335

336+
#[instrument]
337+
#[cfg(feature = "proxy_v0_2_4")]
338+
pub async fn open_image_optional(&self, imgref: &str) -> Result<Option<OpenedImage>> {
339+
tracing::debug!("opening image");
340+
let (imgid, _) = self
341+
.impl_request::<u32, _, _>("OpenImageOptional", [imgref])
342+
.await?;
343+
if imgid == 0 {
344+
Ok(None)
345+
} else {
346+
Ok(Some(OpenedImage(imgid)))
347+
}
348+
}
349+
336350
#[instrument]
337351
pub async fn close_image(&self, img: &OpenedImage) -> Result<()> {
338352
tracing::debug!("closing image");

0 commit comments

Comments
 (0)