/// Parse settings from a saved file.
Parse settings from a saved file.
Parse settings from a saved file .
fn parse_config(config_path: &str) -> NodeConfig {
    let mut settings = Config::default();
    settings.set_default("log-type", "Stderr").expect("Can't set default value for `log-type`");
    settings.set_default("motd", "This is tox-rs").expect("Can't set default value for `motd`");
    settings.set_default("lan-discovery", "False").expect("Can't set default value for `lan-discovery`");
    settings.set_default("threads", "1").expect("Can't set default value for `threads`");
    settings.set_default("tcp-connections-limit", "512").expect("Can't set default value for `tcp-connections-limit`");
    let config_file = if !Path::new(config_path).exists() {
        panic!("Can't find config file {}", config_path);
    } else {
        CfgFile::with_name(config_path)
    };
    settings.merge(config_file).expect("Merging config file with default values failed");
    let config: NodeConfig = settings.try_into().expect("Can't deserialize config");
    if config.keys_file.is_none() {
        panic!("Can't deserialize config: 'keys-file' is not set");
    }
    config
}
fn parse_config ( config_path : & str ) -> NodeConfig { let mut settings = Config :: default ( ) ; settings . set_default ( " " , " " ) . expect ( " " ) ; settings . set_default ( " " , " " ) . expect ( " " ) ; settings . set_default ( " " , " " ) . expect ( " " ) ; settings . set_default ( " " , " " ) . expect ( " " ) ; settings . set_default ( " " , " " ) . expect ( " " ) ; let config_file = if ! Path :: new ( config_path ) . exists ( ) { panic ! ( " " config_path ) ; } else { CfgFile :: with_name ( config_path ) } ; settings . merge ( config_file ) . expect ( " " ) ; let config : NodeConfig = settings . try_into ( ) . expect ( " " ) ; if config . keys_file . is_none ( ) { panic ! ( " " ) ; } config }
Parse settings from a saved file.
Parse settings from a saved file .
config_path
&str