Struct tor_config::sources::ConfigurationSources
source · 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>
) -> Selfwhere
F: Into<PathBuf>,
O: Into<String>,
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> ) -> Selfwhere F: Into<PathBuf>, O: Into<String>,
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>where
F: Into<PathBuf>,
O: Into<String>,
DEF: IntoIterator<Item = ConfigurationSource>,
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>where F: Into<PathBuf>, O: Into<String>, DEF: IntoIterator<Item = ConfigurationSource>,
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
sourcepub fn load(&self) -> Result<Config, ConfigError>
pub fn load(&self) -> Result<Config, ConfigError>
Scan for files and load the configuration into a new [config::Config
].
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 more