pub fn load_config_file () -> SettingsContext {
    let config_result = fs::read_to_string("config.toml");
    let mut config_file = "".to_string();
    let mut config_msg = "Loaded user settings from config.".to_string();
    let mut log_warning = false;
    let mut log_error = false;
    match config_result {
        Ok(t) => {
            config_file = t;
        },
        Err(e) => {
            config_msg = format!("Unable to find config file: {}; Making a new one with default settings", e);
            create_new_config_file(Default::default());
            log_warning = true;
        },
    }

    let settings : Settings = if log_warning {
        Default::default()
    } else {
        let deserialized_result  : Result<Settings, toml::de::Error> = toml::from_str(&config_file);
        let deserialized;
        match deserialized_result {
            Ok(t) => {
                deserialized = t;
            },
            Err(e) => {
                config_msg = format!("Error within config file : {}; Falling back to default settings.", e);
                log_error = true;
                deserialized = Default::default();
            },
        }
        deserialized
    };

    SettingsContext {
        settings : settings,
        message : config_msg,
        log_warning : log_warning,
        log_error : log_error,
    }
}
///Attempts to load user settings from the config.toml file. If the file is not found, a new config file, with default values, will be created.
///If a file is found but contains syntax errors, default values will be used during runtime. Returns a SettingsContext. 
Attempts to load user settings from the config.toml file. If the file is not found, a new config file, with default values, will be created.
If a file is found but contains syntax errors, default values will be used during runtime.
Attempts to load user settings from the config . toml file . If the file is not found a new config file with default values will be created . If a file is found but contains syntax errors default values will be used during runtime .
pub fn load_config_file () -> SettingsContext {
    let config_result = fs::read_to_string("config.toml");
    let mut config_file = "".to_string();
    let mut config_msg = "Loaded user settings from config.".to_string();
    let mut log_warning = false;
    let mut log_error = false;
    match config_result {
        Ok(t) => {
            config_file = t;
        },
        Err(e) => {
            config_msg = format!("Unable to find config file: {}; Making a new one with default settings", e);
            create_new_config_file(Default::default());
            log_warning = true;
        },
    }
    let settings : Settings = if log_warning {
        Default::default()
    } else {
        let deserialized_result  : Result<Settings, toml::de::Error> = toml::from_str(&config_file);
        let deserialized;
        match deserialized_result {
            Ok(t) => {
                deserialized = t;
            },
            Err(e) => {
                config_msg = format!("Error within config file : {}; Falling back to default settings.", e);
                log_error = true;
                deserialized = Default::default();
            },
        }
        deserialized
    };
    SettingsContext {
        settings : settings,
        message : config_msg,
        log_warning : log_warning,
        log_error : log_error,
    }
}
pub fn load_config_file ( ) -> SettingsContext { let config_result = fs :: read_to_string ( " " ) ; let mut config_file = " " . to_string ( ) ; let mut config_msg = " " . to_string ( ) ; let mut log_warning = false ; let mut log_error = false ; match config_result { Ok ( t ) => { config_file = t ; } , Err ( e ) => { config_msg = format ! ( " " e ) ; create_new_config_file ( Default :: default ( ) ) ; log_warning = true ; } , } let settings : Settings = if log_warning { Default :: default ( ) } else { let deserialized_result : Result < Settings , toml :: de :: Error > = toml :: from_str ( & config_file ) ; let deserialized ; match deserialized_result { Ok ( t ) => { deserialized = t ; } , Err ( e ) => { config_msg = format ! ( " " e ) ; log_error = true ; deserialized = Default :: default ( ) ; } , } deserialized } ; SettingsContext { settings : settings , message : config_msg , log_warning : log_warning , log_error : log_error , } }
Attempts to load user settings from the config.toml file.
Attempts to load user settings from the config . toml file .