Skip to main content

PinDefect

Enum PinDefect 

Source
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.

Fields

§after_at: String

Everything after the last @, as written.

§

MalformedDigest

@sha256: followed by something that is not a sha256 digest — truncated, over-long, empty, or not hexadecimal.

Fields

§given: String

What followed @sha256:, as written.

Implementations§

Source§

impl PinDefect

Source

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§

Source§

impl Clone for PinDefect

Source§

fn clone(&self) -> PinDefect

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PinDefect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for PinDefect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

The clause after “…which”, so each defect states what is true of the reference that was actually received.

Source§

impl Eq for PinDefect

Source§

impl PartialEq for PinDefect

Source§

fn eq(&self, other: &PinDefect) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PinDefect

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.