[−][src]Trait tari_common::configuration::loader::ConfigPath
Load struct from config's main section and subsection override
Implementation of this trait along with Deserialize grants ConfigLoader
implementation
Required methods
fn main_key_prefix() -> &'static str
Main configuration section
fn overload_key_prefix(
config: &Config
) -> Result<Option<String>, ConfigurationError>
config: &Config
) -> Result<Option<String>, ConfigurationError>
Overload values from a key prefix based on some configuration value.
Should return a path to configuration table with overloading values.
Returns ConfigurationError
if key_prefix field has wrong value.
Returns Ok(None) if no overload is required
Provided methods
fn merge_subconfig(config: &Config) -> Result<Config, ConfigurationError>
Merge and produce sub-config from overload_key_prefix to main_key_prefix, which can be used to deserialize Self struct If overload key is not present in config it won't make effect
Implementors
impl<C: NetworkConfigPath> ConfigPath for C
[src]
fn main_key_prefix() -> &'static str
[src]
Returns the string representing the top level configuration category.
For example, in the following TOML file, options for main_key_prefix
would be MainKeyOne
or MainKeyTwo
:
[MainKeyOne]
subkey1=1
[MainKeyTwo]
subkey2=1
fn overload_key_prefix(
config: &Config
) -> Result<Option<String>, ConfigurationError>
[src]
config: &Config
) -> Result<Option<String>, ConfigurationError>
Loads the desired subsection from the config file into the provided config
and merges the results. The
subsection that is selected for merging is determined by the value of the use_network
sub key of the "main"
section. For example, if a TOML configuration file contains the following:
[SectionA]
use_network=foo
subkey=1
[SectionA.foo]
subkey=2
[SectionA.baz]
subkey=3
the result after calling merge_config
would have the struct's subkey
value set to 2. If use_network
were omitted, subkey
would be 1, and if use_network
were set to baz
, subkey
would be 3.