@@ -8,6 +8,7 @@ use anyhow::{anyhow, Context, Result};
88use cap_std_ext:: prelude:: CapStdExtCommandExt ;
99use cap_std_ext:: { cap_std, cap_tempfile} ;
1010use futures_util:: Future ;
11+ use oci_spec:: image:: { Descriptor , Digest } ;
1112use serde:: { Deserialize , Serialize } ;
1213use std:: fs:: File ;
1314use std:: ops:: Range ;
@@ -234,10 +235,10 @@ impl TryFrom<ImageProxyConfig> for Command {
234235pub struct ConvertedLayerInfo {
235236 /// Uncompressed digest of a layer; for more information, see
236237 /// https://github.com/opencontainers/image-spec/blob/main/config.md#layer-diffid
237- pub digest : String ,
238+ pub digest : Digest ,
238239
239240 /// Size of blob
240- pub size : i64 ,
241+ pub size : u64 ,
241242
242243 /// Mediatype of blob
243244 pub media_type : oci_spec:: image:: MediaType ,
@@ -474,7 +475,7 @@ impl ImageProxy {
474475 pub async fn get_blob (
475476 & self ,
476477 img : & OpenedImage ,
477- digest : & str ,
478+ digest : & Digest ,
478479 size : u64 ,
479480 ) -> Result < (
480481 impl AsyncBufRead + Send + Unpin ,
@@ -493,6 +494,20 @@ impl ImageProxy {
493494 Ok ( ( fd, finish) )
494495 }
495496
497+ /// Fetch a descriptor. The requested size and digest are verified (by the proxy process).
498+ #[ instrument]
499+ pub async fn get_descriptor (
500+ & self ,
501+ img : & OpenedImage ,
502+ descriptor : & Descriptor ,
503+ ) -> Result < (
504+ impl AsyncBufRead + Send + Unpin ,
505+ impl Future < Output = Result < ( ) > > + Unpin + ' _ ,
506+ ) > {
507+ self . get_blob ( img, descriptor. digest ( ) , descriptor. size ( ) )
508+ . await
509+ }
510+
496511 ///Returns data that can be used to find the "diffid" corresponding to a particular layer.
497512 #[ instrument]
498513 pub async fn get_layer_info (
0 commit comments