pub enum PinDefect {
Tag,
ImplicitLatest,
NotSha256 {
after_at: String,
},
MalformedDigest {
given: String,
},
}Expand description
What is actually wrong with a reference that is not a digest pin.
§Why this exists at all
NotPinned used to carry no such thing, and its message said “which is a
tag rather than a digest” for every way of failing the check. Three
of the four were not tags. image@sha256:deadbeef is a reference whose
author has already pinned and has pasted the abbreviated digest a registry UI
showed them — and they were told they had typed a tag, and then handed
PIN_IT, which explains why tags are dangerous and how to obtain a digest.
Both halves answer a question they did not ask; neither answers the one they
did. Someone in that position looks at a config line visibly containing a
digest, reads “that is a tag”, and concludes the tool is broken.
The failure was not carelessness in one string. It was that the reason was
thrown away at the point it was known: pinned_digest distinguishes these
cases precisely — the comment at the length check has always said so — and
then routed all of them through one constructor. So the reason is now data
the refusal carries rather than a fact the parser knew and discarded, which
is what stops a future case being added to the check and silently inheriting
somebody else’s sentence.
§The set is closed, and deliberately not #[non_exhaustive]
These are not a taxonomy someone chose; they are the branches of
pinned_digest, which are exhaustive by construction — a reference either
has no @, or has one that does not introduce sha256:, or has one that
does and is followed by something other than 64 hex characters. Marking this
#[non_exhaustive] would imply a fifth is anticipated when the parse says
there cannot be one, and would be weaker documentation than the silence
— the reasoning ADR-0001 records for derived | authored | inferred (#448),
applied where it holds for the same reason.
Variants§
Tag
repo:1.2.3 — a written tag, and therefore a mutable pointer.
ImplicitLatest
repo — neither tag nor digest, which an OCI resolver reads as
:latest.
Its own variant rather than folded into Self::Tag for this module’s
whole reason: it is a mutable pointer and gets the same guidance, but
telling someone who wrote no tag that they wrote one is describing
something they did not do. The remedy is shared; the diagnosis is not.
NotSha256
An @ that does not introduce a sha256 digest — repo@sha512:…, or
something that names no algorithm at all.
Carries the text after the @ rather than a pre-parsed algorithm, so the
message can quote what was written when there is no algorithm to name.
MalformedDigest
@sha256: followed by something that is not a sha256 digest — truncated,
over-long, empty, or not hexadecimal.
Implementations§
Source§impl PinDefect
impl PinDefect
Sourcepub fn guidance(&self) -> Guidance
pub fn guidance(&self) -> Guidance
The guidance that fits this defect.
The method is the point of the type. Three blocks rather than one because
the three readers are in different situations: one has never pinned, one
has pinned by the wrong algorithm, one has pinned correctly and mistyped
the value. A single accurate-but-vague block would be not-false for all
three and useful to none, and would cost PinDefect::Tag the specific,
correct argument that is the reason the whole rule exists.
Trait Implementations§
impl Eq for PinDefect
impl StructuralPartialEq for PinDefect
Auto Trait Implementations§
impl Freeze for PinDefect
impl RefUnwindSafe for PinDefect
impl Send for PinDefect
impl Sync for PinDefect
impl Unpin for PinDefect
impl UnsafeUnpin for PinDefect
impl UnwindSafe for PinDefect
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,
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.