pub(crate) fn load(
        cfg_file_path: &Option<String>,
    ) -> Result<ChildStatusConfig, ()> {
        if let Some(cfg_location) = cfg_file_path {
            ChildStatusConfig::init_config_location(cfg_location);

            debug!("Loading configuration file from {}", cfg_location);
            let cfg = fs::read(cfg_location).unwrap_or_default();
            if cfg.is_empty() {
                Ok(ChildStatusConfig::default())
            } else {
                match serde_yaml::from_slice(&cfg) {
                    Ok(config) => Ok(config),
                    Err(e) => {
                        error!("{}", e);
                        Err(())
                    }
                }
            }
        } else {
            Ok(ChildStatusConfig::default())
        }
    }
/// Load the configuration file if it exists otherwise use default values.
Load the configuration file if it exists otherwise use default values.
Load the configuration file if it exists otherwise use default values .
pub(crate) fn load(
        cfg_file_path: &Option<String>,
    ) -> Result<ChildStatusConfig, ()> {
        if let Some(cfg_location) = cfg_file_path {
            ChildStatusConfig::init_config_location(cfg_location);
            debug!("Loading configuration file from {}", cfg_location);
            let cfg = fs::read(cfg_location).unwrap_or_default();
            if cfg.is_empty() {
                Ok(ChildStatusConfig::default())
            } else {
                match serde_yaml::from_slice(&cfg) {
                    Ok(config) => Ok(config),
                    Err(e) => {
                        error!("{}", e);
                        Err(())
                    }
                }
            }
        } else {
            Ok(ChildStatusConfig::default())
        }
    }
pub ( crate ) fn load ( cfg_file_path : & Option < String > , ) -> Result < ChildStatusConfig , ( ) > { if let Some ( cfg_location ) = cfg_file_path { ChildStatusConfig :: init_config_location ( cfg_location ) ; debug ! ( " " cfg_location ) ; let cfg = fs :: read ( cfg_location ) . unwrap_or_default ( ) ; if cfg . is_empty ( ) { Ok ( ChildStatusConfig :: default ( ) ) } else { match serde_yaml :: from_slice ( & cfg ) { Ok ( config ) => Ok ( config ) , Err ( e ) => { error ! ( " " e ) ; Err ( ( ) ) } } } } else { Ok ( ChildStatusConfig :: default ( ) ) } }
Load the configuration file if it exists otherwise use default values.
Load the configuration file if it exists otherwise use default values .
cfg_file_path
&Option<String>