Struct tor_config::sources::ConfigurationSources
source · [−]pub struct ConfigurationSources { /* private fields */ }
Expand description
A description of where to find our configuration options.
Implementations
sourceimpl 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_file: impl Into<PathBuf>,
config_files_options: impl IntoIterator<Item = F>,
cmdline_toml_override_options: impl IntoIterator<Item = O>
) -> Self where
F: Into<PathBuf>,
O: Into<String>,
pub fn from_cmdline<F, O>(
default_config_file: impl Into<PathBuf>,
config_files_options: impl IntoIterator<Item = F>,
cmdline_toml_override_options: impl IntoIterator<Item = O>
) -> Self where
F: Into<PathBuf>,
O: Into<String>,
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)cmdline_toml_override_options
: Overrides (“key=value”)
The caller should also provide default_config_file
, the default location of the
configuration file. This is used if no file(s) are specified on the command line.
mistrust
is used to check whether the configuration files have appropriate permissions.
sourcepub fn push_file(&mut self, p: impl Into<PathBuf>)
pub fn push_file(&mut self, p: impl Into<PathBuf>)
Add p
to the list of files 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_optional_file(&mut self, p: impl Into<PathBuf>)
pub fn push_optional_file(&mut self, p: impl Into<PathBuf>)
As push_file
, but if the listed file can’t be loaded, loading the
configuration can still 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 files(&self) -> impl Iterator<Item = &Path>
pub fn files(&self) -> impl Iterator<Item = &Path>
Return an iterator over the files that we care about.
sourcepub fn load(&self) -> Result<Config, ConfigError>
pub fn load(&self) -> Result<Config, ConfigError>
Load the configuration into a new config::Config
.
Trait Implementations
sourceimpl Clone for ConfigurationSources
impl Clone for ConfigurationSources
sourcefn clone(&self) -> ConfigurationSources
fn clone(&self) -> ConfigurationSources
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ConfigurationSources
impl Debug for ConfigurationSources
sourceimpl Default for ConfigurationSources
impl Default for ConfigurationSources
sourcefn default() -> ConfigurationSources
fn default() -> ConfigurationSources
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for ConfigurationSources
impl Send for ConfigurationSources
impl Sync for ConfigurationSources
impl Unpin for ConfigurationSources
impl UnwindSafe for ConfigurationSources
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more