fn load_default_settings(&self) -> Result<Option<T>, Error> {
        if let Ok(file) = File::open(self.config_file_path.as_ref()) {
            match serde_json::from_reader(BufReader::new(file)) {
                Ok(config) => {
                    // Success path.
                    self.report_config_load(config::base::Event::Load(
                        config::base::ConfigLoadInfo {
                            path: self.config_file_path.to_string(),
                            status: config::base::ConfigLoadStatus::Success,
                        },
                    ));
                    Ok(config)
                }
                Err(e) => {
                    // Found file, but failed to parse.
                    let err_msg = format!("unable to parse config: {:?}", e);
                    self.report_config_load(config::base::Event::Load(
                        config::base::ConfigLoadInfo {
                            path: self.config_file_path.to_string(),
                            status: config::base::ConfigLoadStatus::ParseFailure(err_msg.clone()),
                        },
                    ));
                    Err(format_err!("{:?}", err_msg))
                }
            }
        } else {
            // No file found.
            self.report_config_load(config::base::Event::Load(config::base::ConfigLoadInfo {
                path: self.config_file_path.to_string(),
                status: config::base::ConfigLoadStatus::UsingDefaults(
                    "File not found, using defaults".to_string(),
                ),
            }));
            Ok(self.default_value.clone())
        }
    }
/// Attempts to load the settings from the given config_file_path.
///
/// Returns the default value if unable to read or parse the file. The returned option will
/// only be None if the default_value was provided as None.
Attempts to load the settings from the given config_file_path.
Returns the default value if unable to read or parse the file. The returned option will
only be None if the default_value was provided as None.
Attempts to load the settings from the given config_file_path . Returns the default value if unable to read or parse the file . The returned option will only be None if the default_value was provided as None .
fn load_default_settings(&self) -> Result<Option<T>, Error> {
        if let Ok(file) = File::open(self.config_file_path.as_ref()) {
            match serde_json::from_reader(BufReader::new(file)) {
                Ok(config) => {
                    // Success path.
                    self.report_config_load(config::base::Event::Load(
                        config::base::ConfigLoadInfo {
                            path: self.config_file_path.to_string(),
                            status: config::base::ConfigLoadStatus::Success,
                        },
                    ));
                    Ok(config)
                }
                Err(e) => {
                    // Found file, but failed to parse.
                    let err_msg = format!("unable to parse config: {:?}", e);
                    self.report_config_load(config::base::Event::Load(
                        config::base::ConfigLoadInfo {
                            path: self.config_file_path.to_string(),
                            status: config::base::ConfigLoadStatus::ParseFailure(err_msg.clone()),
                        },
                    ));
                    Err(format_err!("{:?}", err_msg))
                }
            }
        } else {
            // No file found.
            self.report_config_load(config::base::Event::Load(config::base::ConfigLoadInfo {
                path: self.config_file_path.to_string(),
                status: config::base::ConfigLoadStatus::UsingDefaults(
                    "File not found, using defaults".to_string(),
                ),
            }));
            Ok(self.default_value.clone())
        }
    }
fn load_default_settings ( & self ) -> Result < Option < T > , Error > { if let Ok ( file ) = File :: open ( self . config_file_path . as_ref ( ) ) { match serde_json :: from_reader ( BufReader :: new ( file ) ) { Ok ( config ) => { // Success path. self . report_config_load ( config :: base :: Event :: Load ( config :: base :: ConfigLoadInfo { path : self . config_file_path . to_string ( ) , status : config :: base :: ConfigLoadStatus :: Success , } , ) ) ; Ok ( config ) } Err ( e ) => { // Found file, but failed to parse. let err_msg = format ! ( " " e ) ; self . report_config_load ( config :: base :: Event :: Load ( config :: base :: ConfigLoadInfo { path : self . config_file_path . to_string ( ) , status : config :: base :: ConfigLoadStatus :: ParseFailure ( err_msg . clone ( ) ) , } , ) ) ; Err ( format_err ! ( " " err_msg ) ) } } } else { // No file found. self . report_config_load ( config :: base :: Event :: Load ( config :: base :: ConfigLoadInfo { path : self . config_file_path . to_string ( ) , status : config :: base :: ConfigLoadStatus :: UsingDefaults ( " " . to_string ( ) , ) , } ) ) ; Ok ( self . default_value . clone ( ) ) } }
Attempts to load the settings from the given config_file_path.
Attempts to load the settings from the given config_file_path .
&self
&self