Skip to main content

Resolved

Struct Resolved 

Source
pub struct Resolved {
    pub warnings: Vec<Warning>,
    /* private fields */
}
Expand description

Everything a resolution produced.

Fields§

§warnings: Vec<Warning>

Everything a user should be told, in the order it was found.

Implementations§

Source§

impl Resolved

Source

pub fn fold(&self) -> Fold<'_>

Start reading this resolution as typed values.

Source

pub fn fold_lossy(&self) -> Fold<'_>

Start reading, keeping every setting that does read.

A strict fold reports and yields nothing, so one bad value costs the caller the whole resolution — and a CLI whose only remaining move is Settings::default() has thrown away the environment and every file over a single field. That is not a policy a library gets to choose: erroring, warning and carrying on, or ignoring it outright are all reasonable, and which one is right depends on the CLI. So this hands back both halves and lets it decide.

A setting that will not read falls back to its declared default, which is the value the CLI would have had if the offending layer had said nothing. The error is still recorded — the fallback is not a repair, and a caller that wants to treat it as fatal still can.

Source

pub fn read<T: FromValue>(&self, id: PropId) -> Result<Option<T>, ReadError>

One setting, as the type T holds, with the error naming where the value came from.

For a CLI reading a handful of settings by hand. Generated code uses Resolved::fold, which reports every bad value instead of this one.

Source§

impl Resolved

Source

pub fn get(&self, id: PropId) -> Option<&Value>

The winning value for a setting.

Source

pub fn get_key(&self, key: &str) -> Option<&Value>

The winning value for a dotted key, following renames.

Source

pub fn origin(&self, id: PropId) -> Option<&Origin>

Where the winning value came from.

Source

pub fn origin_key(&self, key: &str) -> Option<&Origin>

Where the winning value for a dotted key came from, following renames.

The counterpart to Resolved::get_key, and the reason this exists: a settings listing walks keys, and without it the only way to ask about provenance was origin(registry.lookup(key)?.id). pitchfork’s first port of settings list reached that wall and fell back to comparing the rendered value against the rendered default, which reports an explicit override that happens to equal the default as unset — the exact confusion an origin-tracked merge exists to end.

Source

pub fn contributors(&self, id: PropId) -> &[Origin]

Every place that contributed to this setting, in merge order.

One entry for a replace setting, several for a union or deep one — which is what makes per-item provenance possible for a list assembled from four files.

Source

pub fn contributors_key(&self, key: &str) -> &[Origin]

Every place that contributed to a dotted key, in merge order, following renames.

Empty for a key the registry does not have, which is the same answer as a key nothing contributed to. A caller that needs to tell the two apart is asking whether the setting exists, and Registry::lookup is that question.

Source

pub fn registry(&self) -> Registry

Source

pub fn coerced(&mut self, id: PropId, value: Value, why: impl Into<String>)

Record that the CLI rewrote a value after merging.

The typed post-merge hook is where a CLI’s own rules live — mise’s raw implying jobs = 1, its ci implying yes. Going through here rather than assigning to the struct keeps explain honest: the origin becomes SourceKind::COERCED with the reason, instead of continuing to name a file that never said it.

Trait Implementations§

Source§

impl Clone for Resolved

Source§

fn clone(&self) -> Resolved

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 Resolved

Source§

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

Formats the value using the given formatter. Read more

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.

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