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
impl Resolved
Sourcepub fn fold_lossy(&self) -> Fold<'_>
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.
Sourcepub fn read<T: FromValue>(&self, id: PropId) -> Result<Option<T>, ReadError>
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
impl Resolved
Sourcepub fn get_key(&self, key: &str) -> Option<&Value>
pub fn get_key(&self, key: &str) -> Option<&Value>
The winning value for a dotted key, following renames.
Sourcepub fn origin_key(&self, key: &str) -> Option<&Origin>
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.
Sourcepub fn contributors(&self, id: PropId) -> &[Origin]
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.
Sourcepub fn contributors_key(&self, key: &str) -> &[Origin]
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.
pub fn registry(&self) -> Registry
Sourcepub fn coerced(&mut self, id: PropId, value: Value, why: impl Into<String>)
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.