pub struct Config { /* private fields */ }Expand description
The settings in force for one invocation.
Holding no credential of its own, this may be rendered in a diagnostic
safely; a credential lives in Secret, which redacts itself.
Implementations§
Source§impl Config
impl Config
Sourcepub fn load(override_dir: Option<&Path>) -> Result<Self>
pub fn load(override_dir: Option<&Path>) -> Result<Self>
Loads the stored settings from the given location.
§Errors
Returns a configuration failure when the location cannot be determined or the file exists and cannot be read.
Sourcepub fn with_nothing_stored(override_dir: Option<&Path>) -> Result<Self>
pub fn with_nothing_stored(override_dir: Option<&Path>) -> Result<Self>
The settings as they stand when the stored file cannot be read at all.
Every setting falls back to its built-in value, which is the same place
Self::load lands when nothing was ever stored. The difference is why
it landed there, and that difference belongs to the caller: this is only
correct for work whose subject IS the unreadable file, and wrong for
everything else, which would silently run against values the caller
never chose.
It exists because config doctor is that work. Reporting an unreadable
file is the reason that command was written, so refusing to serve it
until the file can be read is refusing to serve it exactly when it is
needed.
§Errors
Returns a configuration failure when the location itself cannot be determined. That is a different condition from an unreadable file: there is no path to report on, so there is nothing to diagnose either.
Sourcepub fn with_flag(self, name: &str, raw: &str) -> Result<Self>
pub fn with_flag(self, name: &str, raw: &str) -> Result<Self>
Records one mark from the command line, which outranks everything else.
§Errors
Returns a configuration failure when the name is unknown or the text falls outside the setting’s domain.
Sourcepub fn is_stored(&self, name: &str) -> bool
pub fn is_stored(&self, name: &str) -> bool
Whether a value was written into the file for this setting.
Sourcepub fn resolve(&self, name: &str) -> Result<Resolved>
pub fn resolve(&self, name: &str) -> Result<Resolved>
The value in force for one setting, and the layer that decided it.
§Errors
Returns a configuration failure when the name is unknown, or when a value written into the file falls outside the setting’s domain.
Sourcepub fn resolve_all(
&self,
) -> impl Iterator<Item = (&'static KeySpec, Result<Resolved>)> + '_
pub fn resolve_all( &self, ) -> impl Iterator<Item = (&'static KeySpec, Result<Resolved>)> + '_
Every published setting with the value in force and its origin.
A setting whose stored value no longer passes its domain is carried as a failure rather than skipped, so a broken file is impossible to miss.