pub struct ImageRef { /* private fields */ }Expand description
Image reference that preserves the user’s RAW input string alongside
the parsed canonical ImageReference.
ImageReference (from oci_client) normalizes Docker Hub defaults at
parse time — nginx becomes docker.io/library/nginx. That’s correct
for resolution, but destroys the ability to detect “the user wrote a
bare name and we should look for it locally first.”
ImageRef holds both:
parsed: the canonicalImageReferencefor normalized comparisons, registry calls, and tag/digest extraction.original: the exact bytes the user (or wire format) gave us.
Equality and hashing use the canonical parsed form, so two ImageRefs
resolving to the same image compare equal even if one was qualified.
Display / Serialize use the original, so roundtripping preserves
what the user typed.
Implementations§
Source§impl ImageRef
impl ImageRef
Sourcepub fn from_parsed(parsed: ImageReference) -> Self
pub fn from_parsed(parsed: ImageReference) -> Self
Wrap an already-parsed ImageReference. The original field is
set to the canonical string form, so Self::is_unqualified on the
result will return false (the canonical form always has a host).
Sourcepub fn parsed(&self) -> &ImageReference
pub fn parsed(&self) -> &ImageReference
Access the parsed canonical ImageReference.
Sourcepub fn is_unqualified(&self) -> bool
pub fn is_unqualified(&self) -> bool
Returns true when the user’s original string did NOT include a registry
host (no host[:port]/ prefix). Detection rule: split on the FIRST /;
if there’s no / at all, or the segment before the first / contains
neither . nor : and is not localhost, treat as unqualified.
Examples:
nginx-> unqualifiednginx:latest-> unqualifiedlibrary/nginx-> unqualified (Docker namespace, no host)foo/bar-> unqualifieddocker.io/library/nginx-> qualified (host has.)ghcr.io/foo/bar-> qualified (host has.)localhost/foo-> qualified (literallocalhost)localhost:5000/foo-> qualified (:port)registry:5000/foo-> qualified (:port)
Methods from Deref<Target = ImageReference>§
Sourcepub fn clone_with_digest(&self, digest: String) -> Reference
pub fn clone_with_digest(&self, digest: String) -> Reference
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ImageRef
impl<'de> Deserialize<'de> for ImageRef
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
impl Eq for ImageRef
Auto Trait Implementations§
impl Freeze for ImageRef
impl RefUnwindSafe for ImageRef
impl Send for ImageRef
impl Sync for ImageRef
impl Unpin for ImageRef
impl UnsafeUnpin for ImageRef
impl UnwindSafe for ImageRef
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FromBase64 for Twhere
T: for<'de> Deserialize<'de>,
impl<T> FromBase64 for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<C> SignWithKey<String> for Cwhere
C: ToBase64,
impl<C> SignWithKey<String> for Cwhere
C: ToBase64,
fn sign_with_key(self, key: &impl SigningAlgorithm) -> Result<String, Error>
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.