Skip to main content

Config

Struct Config 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn file(&self) -> &Path

Where the settings file lives for this invocation.

Source

pub fn is_stored(&self, name: &str) -> bool

Whether a value was written into the file for this setting.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Config

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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