pub struct Reference { /* private fields */ }Expand description
Reference provides a general type to represent any way of referencing images within an OCI registry.
§Examples
Parsing a tagged image reference:
use oci_spec::distribution::Reference;
let reference: Reference = "docker.io/library/hello-world:latest".parse().unwrap();
assert_eq!("docker.io/library/hello-world:latest", reference.whole().as_str());
assert_eq!("docker.io", reference.registry());
assert_eq!("library/hello-world", reference.repository());
assert_eq!(Some("latest"), reference.tag());
assert_eq!(None, reference.digest());Implementations§
Source§impl Reference
impl Reference
Sourcepub fn with_tag(registry: String, repository: String, tag: String) -> Self
pub fn with_tag(registry: String, repository: String, tag: String) -> Self
Create a Reference with a registry, repository and tag.
Sourcepub fn with_digest(registry: String, repository: String, digest: String) -> Self
pub fn with_digest(registry: String, repository: String, digest: String) -> Self
Create a Reference with a registry, repository and digest.
Sourcepub fn with_tag_and_digest(
registry: String,
repository: String,
tag: String,
digest: String,
) -> Self
pub fn with_tag_and_digest( registry: String, repository: String, tag: String, digest: String, ) -> Self
Create a new instance of Reference with a registry, repository, tag and digest.
This is useful when you need to reference an image by both its semantic version (tag) and its content-addressable digest for immutability.
§Examples
use oci_spec::distribution::Reference;
let reference = Reference::with_tag_and_digest(
"docker.io".to_string(),
"library/nginx".to_string(),
"1.21".to_string(),
"sha256:abc123...".to_string(),
);Sourcepub fn clone_with_digest(&self, digest: String) -> Self
pub fn clone_with_digest(&self, digest: String) -> Self
Clone the Reference for the same image with a new digest.
Sourcepub fn resolve_registry(&self) -> &str
pub fn resolve_registry(&self) -> &str
Resolve the registry address of a given Reference.
Some registries, such as docker.io, uses a different address for the actual registry. This function implements such redirection.
If a mirror registry is set, it will be used instead of the original registry.
Sourcepub fn repository(&self) -> &str
pub fn repository(&self) -> &str
Returns the name of the repository.