66
77pub mod transport;
88
9+ // Re-export oci_spec so consumers don't need to add it as a dependency.
10+ // NOTE: Bumping oci_spec in a semver-incompatible way requires bumping this crate too.
11+ // See Cargo.toml for details.
12+ pub use :: oci_spec;
13+ pub use transport:: {
14+ ContainersStorageRef , ImageReference , ImageReferenceError , Transport , TransportConversionError ,
15+ } ;
16+
17+ use :: oci_spec:: image:: { Descriptor , Digest } ;
918use cap_std_ext:: prelude:: CapStdExtCommandExt ;
1019use cap_std_ext:: { cap_std, cap_tempfile} ;
1120use futures_util:: { Future , FutureExt } ;
1221use itertools:: Itertools ;
13- use oci_spec:: image:: { Descriptor , Digest } ;
1422use serde:: { Deserialize , Serialize } ;
1523use std:: fs:: File ;
1624use std:: iter:: FusedIterator ;
@@ -90,9 +98,6 @@ impl From<rustix::io::Errno> for Error {
9098/// The error type returned from this crate.
9199pub type Result < T > = std:: result:: Result < T , Error > ;
92100
93- /// Re-export because we use this in our public APIs
94- pub use oci_spec;
95-
96101/// File descriptor range which is reserved for passing data down into the proxy;
97102/// avoid configuring the command to use files in this range. (Also, stdin is
98103/// reserved)
@@ -586,13 +591,22 @@ impl ImageProxy {
586591 Ok ( r)
587592 }
588593
594+ /// Open an image for fetching, using a string reference.
589595 #[ instrument]
590596 pub async fn open_image ( & self , imgref : & str ) -> Result < OpenedImage > {
591597 tracing:: debug!( "opening image" ) ;
592598 let imgid = self . impl_request ( "OpenImage" , [ imgref] ) . await ?;
593599 Ok ( OpenedImage ( imgid) )
594600 }
595601
602+ /// Open an image for fetching, using a structured [`ImageReference`].
603+ #[ instrument]
604+ pub async fn open_image_ref ( & self , imgref : & ImageReference ) -> Result < OpenedImage > {
605+ self . open_image ( & imgref. to_string ( ) ) . await
606+ }
607+
608+ /// Open an image for fetching if it exists, using a string reference.
609+ /// Returns `Ok(None)` if the image does not exist.
596610 #[ instrument]
597611 pub async fn open_image_optional ( & self , imgref : & str ) -> Result < Option < OpenedImage > > {
598612 tracing:: debug!( "opening image" ) ;
@@ -604,6 +618,16 @@ impl ImageProxy {
604618 }
605619 }
606620
621+ /// Open an image for fetching if it exists, using a structured [`ImageReference`].
622+ /// Returns `Ok(None)` if the image does not exist.
623+ #[ instrument]
624+ pub async fn open_image_optional_ref (
625+ & self ,
626+ imgref : & ImageReference ,
627+ ) -> Result < Option < OpenedImage > > {
628+ self . open_image_optional ( & imgref. to_string ( ) ) . await
629+ }
630+
607631 #[ instrument]
608632 pub async fn close_image ( & self , img : & OpenedImage ) -> Result < ( ) > {
609633 self . impl_request ( "CloseImage" , [ img. 0 ] ) . await
0 commit comments