pub struct Reference<'a> {
pub registry: &'a str,
pub repository: Repository<'a>,
pub tag: &'a str,
pub digest: Option<Digest>,
}Expand description
Reference to an image in an OCI registry.
The parser tries to be close to what docker pull does:
-
If the reference does not include the hostname of the registry, it uses Docker Hub, and the repository namespace defaults to
libraryif there is none. For example:debianis parsed asregistry-1.docker.io/library/debian.nixos/nixis parsed asregistry-1.docker.io/nixos/nix.
-
It accepts any tag value after the last
:character. If no tag is given, it useslatest. -
It accepts a fixed digest (the last part after a
@character), but only SHA256 and SHA512.
However, it does not try to be bug-for-bug compatible with Docker.
§Examples
const REFERENCE: &str = "registry.example.com/foo/bar:1.23.4@sha256:123456789012345678901234567890123456789012345678901234567890ABCD";
let reference = Reference::try_from(REFERENCE).unwrap();
assert_eq!(reference.registry, "registry.example.com");
assert_eq!(reference.repository.namespace(), Some("foo"));
assert_eq!(reference.repository.name(), "bar");
assert_eq!(reference.tag, "1.23.4");
let digest = reference.digest.as_ref().unwrap();
assert_eq!(digest.algorithm(), DigestAlgorithm::SHA256);
assert_eq!(digest.hash_value(), "123456789012345678901234567890123456789012345678901234567890ABCD");let reference = Reference::try_from("debian:stable").unwrap();
assert_eq!(reference.repository.to_string(), "library/debian");
assert_eq!(reference.tag, "stable");Fields§
§registry: &'a strAddress of the registry server.
repository: Repository<'a>Repository name.
tag: &'a strImage tag.
digest: Option<Digest>Manifest digest, if present.
Trait Implementations§
impl<'a> StructuralPartialEq for Reference<'a>
Auto Trait Implementations§
impl<'a> Freeze for Reference<'a>
impl<'a> RefUnwindSafe for Reference<'a>
impl<'a> Send for Reference<'a>
impl<'a> Sync for Reference<'a>
impl<'a> Unpin for Reference<'a>
impl<'a> UnwindSafe for Reference<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more