pub struct ConfigurationSources { /* private fields */ }
Expand description
A description of where to find our configuration options.
Implementations§
Source§impl ConfigurationSources
impl ConfigurationSources
Sourcepub fn new_empty() -> Self
pub fn new_empty() -> Self
Create a new empty ConfigurationSources
.
Sourcepub fn from_cmdline<F, O>(
default_config_files: impl IntoIterator<Item = ConfigurationSource>,
config_files_options: impl IntoIterator<Item = F>,
cmdline_toml_override_options: impl IntoIterator<Item = O>,
) -> Self
pub fn from_cmdline<F, O>( default_config_files: impl IntoIterator<Item = ConfigurationSource>, config_files_options: impl IntoIterator<Item = F>, cmdline_toml_override_options: impl IntoIterator<Item = O>, ) -> Self
Establish a ConfigurationSources
the from an infallible command line and defaults
Convenience method for if the default config file location(s) can be infallibly computed.
Sourcepub fn try_from_cmdline<F, O, DEF, E>(
default_config_files: impl FnOnce() -> Result<DEF, E>,
config_files_options: impl IntoIterator<Item = F>,
cmdline_toml_override_options: impl IntoIterator<Item = O>,
) -> Result<Self, E>
pub fn try_from_cmdline<F, O, DEF, E>( default_config_files: impl FnOnce() -> Result<DEF, E>, config_files_options: impl IntoIterator<Item = F>, cmdline_toml_override_options: impl IntoIterator<Item = O>, ) -> Result<Self, E>
Establish a ConfigurationSources
the usual way from a command line and defaults
The caller should have parsed the program’s command line, and extracted (inter alia)
config_files_options
: Paths of config file(s) (or directories of.toml
files)cmdline_toml_override_options
: Overrides (“key=value”)
The caller should also provide default_config_files
,
which returns the default locations of the configuration files.
This used if no file(s) are specified on the command line.
mistrust
is used to check whether the configuration files have appropriate permissions.
ConfigurationSource::Dir
s
will be scanned for files whose name ends in .toml
.
All those files (if any) will be read (in lexical order by filename).
Sourcepub fn push_source(&mut self, src: ConfigurationSource, must_read: MustRead)
pub fn push_source(&mut self, src: ConfigurationSource, must_read: MustRead)
Add src
to the list of files or directories that we want to read configuration from.
Configuration files are loaded and applied in the order that they are added to this object.
If the listed file is absent, loading the configuration won’t succeed.
Sourcepub fn push_option(&mut self, option: impl Into<String>)
pub fn push_option(&mut self, option: impl Into<String>)
Add s
to the list of overridden options to apply to our configuration.
Options are applied after all configuration files are loaded, in the order that they are added to this object.
The format for s
is as in CmdLine
.
Sourcepub fn set_mistrust(&mut self, mistrust: Mistrust)
pub fn set_mistrust(&mut self, mistrust: Mistrust)
Sets the filesystem permission mistrust
This value only indicates whether and how to check permissions
on the configuration file itself.
It does not specify whether and how to check permissions of the
paths provided within.
This is defined by the storage.permissions.dangerously_trust_everyone
flag.
Sourcepub fn mistrust(&self) -> &Mistrust
pub fn mistrust(&self) -> &Mistrust
Reads the filesystem permission mistrust
This value only indicates whether and how to check permissions
on the configuration file itself.
It does not specify whether and how to check permissions of the
paths provided within.
This is defined by the storage.permissions.dangerously_trust_everyone
flag.
Sourcepub fn load(&self) -> Result<ConfigurationTree, ConfigError>
pub fn load(&self) -> Result<ConfigurationTree, ConfigError>
Scan for files and load the configuration into a new ConfigurationTree
.
This is a convenience method for scan()
followed by [files.load
].
Sourcepub fn scan(&self) -> Result<FoundConfigFiles<'_>, ConfigError>
pub fn scan(&self) -> Result<FoundConfigFiles<'_>, ConfigError>
Scan for configuration source files (including scanning any directories)
Trait Implementations§
Source§impl Clone for ConfigurationSources
impl Clone for ConfigurationSources
Source§fn clone(&self) -> ConfigurationSources
fn clone(&self) -> ConfigurationSources
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ConfigurationSources
impl Debug for ConfigurationSources
Source§impl Default for ConfigurationSources
impl Default for ConfigurationSources
Source§fn default() -> ConfigurationSources
fn default() -> ConfigurationSources
Auto Trait Implementations§
impl Freeze for ConfigurationSources
impl RefUnwindSafe for ConfigurationSources
impl Send for ConfigurationSources
impl Sync for ConfigurationSources
impl Unpin for ConfigurationSources
impl UnwindSafe for ConfigurationSources
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more