Skip to main content

AttemptOutcome

Enum AttemptOutcome 

Source
#[non_exhaustive]
pub enum AttemptOutcome { Disabled { env: &'static [&'static str], }, NotApplicable, WrongPublisher { detail: String, }, NotNeeded, NoRecord, NotOpenAccess { detail: String, }, Denied { denial: DenialContext, }, Failed { detail: String, }, Resolved, }
Expand description

Why a given optional source did or did not contribute.

The distinction this type exists to make: “we asked and it had nothing” is not the same failure as “we never asked”. Before this, both looked identical from outside — a DOI fetch that failed returned the Crossref error and said nothing about the rest of the chain, so a user could not tell whether HAL had been consulted and come up empty, or whether DOIGET_ENABLE_HAL was simply unset. One means the paper is not there; the other means you have not turned the source on. They need completely different actions.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Disabled

Runtime flag unset — not consulted. Carries the env var so the message can name the exact thing the user has to change.

Fields

§env: &'static [&'static str]

Every variable that has to be set, e.g. ["DOIGET_ENABLE_HAL"] or ["DOIGET_KEY_APS", "DOIGET_AGREE_TDM_APS"].

A list rather than a string because Tier 3 needs two, and joining them into "A + B" put a separator on the #459 wire that a consumer would have had to split on — which is the thing the detail() / wire() split exists to avoid (#470).

§

NotApplicable

This source cannot serve this kind of ref at all (e.g. an arXiv id handed to a DOI-only resolver). Not a misconfiguration.

§

WrongPublisher

Not consulted. A publisher-specific Tier-3 source was asked about a DOI its publisher did not register (#442).

Distinct from Self::Disabled on purpose: the credentials are fine and there is nothing for the user to switch on. Telling them to set DOIGET_KEY_APS because an Elsevier DOI did not resolve would send them after the wrong problem.

Fields

§detail: String

e.g. "DOI prefix 10.1016 is not American Physical Society (APS)".

§

NotNeeded

An earlier source in the chain already answered, so this one was deliberately skipped. Not a failure.

§

NoRecord

Consulted. The source has no record for this ref.

§

NotOpenAccess

Consulted. A record exists but is not open access — the source knows the paper and still cannot give it to us.

Fields

§detail: String

Source-specific detail, e.g. the access-rights code observed.

§

Denied

Consulted, and refused by a policy control with a structured reason: a redirect off the allowlist, an insecure redirect, an oversized body, a not-a-PDF (ADR-0023).

Distinct from Self::Failed because the DenialContext is what crate::remediation::for_denial consumes. PdfLegStatus::Blocked kept it end to end and the MCP layer turned it into a remediation; per-source rows flattened the same information to prose, so the richest and most actionable case degraded to text on a wire that #459 advertises as machine-readable (#470).

Fields

§denial: DenialContext

The structured denial, verbatim.

§

Failed

Consulted. The request itself failed (transport, auth, schema).

Fields

§detail: String

Rendered error.

§

Resolved

Consulted, and it answered.

Implementations§

Source§

impl AttemptOutcome

Source

pub fn was_consulted(&self) -> bool

Whether a request actually went out for this source.

This is the predicate the reachability tests assert on: a source reporting was_consulted() == false is one the production path never reached, which is exactly the condition that used to be invisible.

Source

pub fn wire(&self) -> &'static str

Stable machine token for this outcome (#459).

Self::render is prose and may be reworded; this is the thing a consumer branches on. Kept separate for that reason — the CLI has already reworded the trace twice (#413, #438) and a caller keying off the sentence would have broken both times.

The two halves of the vocabulary mirror Self::was_consulted: not_consulted_* means no request went out, consulted_* means one did. That distinction is the entire reason this type exists.

Source

pub fn detail(&self) -> Option<&str>

The variant’s free-text payload, when it has one.

Carried separately from Self::wire so a consumer gets the actionable specifics — which env var, which prefix, which error — without parsing them back out of the rendered sentence.

Source

pub fn required_env(&self) -> Option<&'static [&'static str]>

The variables a Disabled row needs set, in the order the user should set them. None for every other outcome.

Source

pub fn denial(&self) -> Option<&DenialContext>

The structured denial behind a Denied row, which is what crate::remediation::for_denial takes. None otherwise.

Source

pub fn render(&self) -> String

One-line rendering, phrased so consulted and not-consulted cannot be misread for one another.

Trait Implementations§

Source§

impl Clone for AttemptOutcome

Source§

fn clone(&self) -> AttemptOutcome

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 AttemptOutcome

Source§

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

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

impl Eq for AttemptOutcome

Source§

impl PartialEq for AttemptOutcome

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for AttemptOutcome

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more