[][src]Module tari_common::configuration::loader

Application configuration

Tari is using config crate which allows to extend config file with application level configs. To allow deriving configuration from a Config via ConfigLoader trait application configuration struct should implements Deserialize and NetworkConfigPath traits.

ConfigLoader::load_from logic will include automated overloading of parameters from [application.{network}] subsection, where network is specified in application.network parameter.

ConfigPath allows to customize overloading logic event further and DefaultConfigLoader trait accounts for struct Defaults when loading values.

Example

#[derive(Deserialize)]
struct MyNodeConfig {
    welcome_message: String,
}
impl NetworkConfigPath for MyNodeConfig {
    fn main_key_prefix() -> &'static str {
        "my_node"
    }
}

config.set("my_node.network", "rincewind");
config.set("my_node.rincewind.welcome_message", "nice to see you at unseen");
let my_config = <MyNodeConfig as ConfigLoader>::load_from(&config).unwrap();
assert_eq!(my_config.welcome_message, "nice to see you at unseen");

Structs

ConfigurationError

Traits

ConfigLoader

Configuration loader based on ConfigPath selectors

ConfigPath

Load struct from config's main section and subsection override

DefaultConfigLoader

Configuration loader based on ConfigPath selectors with Defaults

NetworkConfigPath

Load struct from config's main section and network subsection override