/// Create a new image given a specific repository
///
/// Consider using [Registry::image] instead.
///
/// The type parameter has a trait bound on [ImageSelector], which can
/// be implemented to select which image to use when pulling from a
/// fat manifest.
/// For most cases the [ImagePlatformSelector] should do just fine.
///
/// # Example
/// ```
///# extern crate opencontainers;
///# use opencontainers::Registry;
///# use opencontainers::image::TestImageSelector as ImagePlatformSelector;
///# let registry = Registry::new("https://registry-1.docker.io");
/// let image = opencontainers::Image::new::<ImagePlatformSelector>(&registry, "library/hello-world", "latest")
///     .expect("Could not get image");
/// ```
Create a new image given a specific repository
Consider using [Registry::image] instead.

The type parameter has a trait bound on [ImageSelector], which can
be implemented to select which image to use when pulling from a
fat manifest.
For most cases the [ImagePlatformSelector] should do just fine.

Example
```
Create a new image given a specific repository Consider using [ Registry :: image ] instead . The type parameter has a trait bound on [ ImageSelector ] which can be implemented to select which image to use when pulling from a fat manifest . For most cases the [ ImagePlatformSelector ] should do just fine . Example ` ` `
pub fn new<IS>(
        registry: &'a Registry,
        name: &str,
        reference: &str,
    ) -> Result<Self, RegistryError>
    where
        IS: ImageSelector,
    {
        let name = name.to_owned();
        let url = format!("{}/v2/{}/manifests/{}", registry.url, name, reference);
        // Make sure we only accept schema 2, if we don't set this, we will get
        // schema1 by default.
        // For now, do not support Manifest Lists.
        let accept_types = vec![
            "application/vnd.oci.distribution.manifest.list.v2+json",
            "application/vnd.oci.distribution.manifest.v2+json",
            "application/vnd.docker.distribution.manifest.list.v2+json",
            "application/vnd.docker.distribution.manifest.v2+json",
        ];
        let mut headers = reqwest::header::HeaderMap::new();
        headers.insert(
            reqwest::header::ACCEPT,
            accept_types.join(",").parse().unwrap(),
        );
        let manifest = registry
            .get(&url, Some(&headers))?
            .text()
            .map_err(RegistryError::ReqwestError)?
            .parse()
            .map_err(RegistryError::ManifestError)?;
        let mut image = Self {
            registry,
            name,
            manifest,
        };
        if let ManifestV2::Schema2List(ref l) = image.manifest {
            image.manifest = ManifestV2::Schema2(l.get_current_platform_manifest::<IS>(&image)?);
        };
        Ok(image)
    }
pub fn new < IS > ( registry : & ' a Registry , name : & str , reference : & str , ) -> Result < Self , RegistryError > where IS : ImageSelector , { let name = name . to_owned ( ) ; let url = format ! ( " " registry url name reference ) ; // Make sure we only accept schema 2, if we don't set this, we will get // schema1 by default. // For now, do not support Manifest Lists. let accept_types = vec ! [ " " " " " " " " ] ; let mut headers = reqwest :: header :: HeaderMap :: new ( ) ; headers . insert ( reqwest :: header :: ACCEPT , accept_types . join ( " " ) . parse ( ) . unwrap ( ) , ) ; let manifest = registry . get ( & url , Some ( & headers ) ) ? . text ( ) . map_err ( RegistryError :: ReqwestError ) ? . parse ( ) . map_err ( RegistryError :: ManifestError ) ? ; let mut image = Self { registry , name , manifest , } ; if let ManifestV2 :: Schema2List ( ref l ) = image . manifest { image . manifest = ManifestV2 :: Schema2 ( l . get_current_platform_manifest :: < IS > ( & image ) ? ) ; } ; Ok ( image ) }
Create a new image given a specific repository
Consider using [Registry::image] instead.
Create a new image given a specific repository Consider using [ Registry :: image ] instead .
registry
&'a Registry
name
&str
reference
&str
extern crate opencontainers;
None
use opencontainers::registry;
None
use opencontainers::image::testimageselector as imageplatformselector;
None
let registry = registry::new("https://registry-1.docker.io");
let image = opencontainers::Image::new::(&registry, "library/hello-world", "latest")
.expect("Could not get image");
```
let image = opencontainers :: Image :: new :: ( &registry " library / hello - world " " latest " ) . expect ( " Could not get image " ) ; ` ` `