pub fn read<P>(file: P) -> Result<Config, serde_yaml::Error>
    where
        P: AsRef<Path> + Display + ToString,
    {
        debug!("loading configuration file from {}", file);
        let cfg = fs::read(&file).unwrap_or_default();
        let mut config;
        // only parse the file when its not empty, otherwise
        // just store the filepath to write it out later
        if !cfg.is_empty() {
            match serde_yaml::from_slice(&cfg) {
                Ok(v) => config = v,
                Err(e) => {
                    error!("{}", e);
                    return Err(e);
                }
            };
        } else {
            info!("Config file {} is empty, reverting to default config", file);
            // the file is empty
            config = Config::default();
        }

        if !config.sync_disable {
            // use the source luke!
            config.source = Some(file.to_string());
        }
        Ok(config)
    }
/// read the config file from disk. If the config file is empty, return the
/// default config, but store the empty config file with in the struct to be
/// used during saving to disk.
read the config file from disk. If the config file is empty, return the
default config, but store the empty config file with in the struct to be
used during saving to disk.
read the config file from disk . If the config file is empty return the default config but store the empty config file with in the struct to be used during saving to disk .
pub fn read<P>(file: P) -> Result<Config, serde_yaml::Error>
    where
        P: AsRef<Path> + Display + ToString,
    {
        debug!("loading configuration file from {}", file);
        let cfg = fs::read(&file).unwrap_or_default();
        let mut config;
        // only parse the file when its not empty, otherwise
        // just store the filepath to write it out later
        if !cfg.is_empty() {
            match serde_yaml::from_slice(&cfg) {
                Ok(v) => config = v,
                Err(e) => {
                    error!("{}", e);
                    return Err(e);
                }
            };
        } else {
            info!("Config file {} is empty, reverting to default config", file);
            // the file is empty
            config = Config::default();
        }
        if !config.sync_disable {
            // use the source luke!
            config.source = Some(file.to_string());
        }
        Ok(config)
    }
pub fn read < P > ( file : P ) -> Result < Config , serde_yaml :: Error > where P : AsRef < Path > + Display + ToString , { debug ! ( " " file ) ; let cfg = fs :: read ( & file ) . unwrap_or_default ( ) ; let mut config ; // only parse the file when its not empty, otherwise // just store the filepath to write it out later if ! cfg . is_empty ( ) { match serde_yaml :: from_slice ( & cfg ) { Ok ( v ) => config = v , Err ( e ) => { error ! ( " " e ) ; return Err ( e ) ; } } ; } else { info ! ( " " file ) ; // the file is empty config = Config :: default ( ) ; } if ! config . sync_disable { // use the source luke! config . source = Some ( file . to_string ( ) ) ; } Ok ( config ) }
read the config file from disk.
read the config file from disk .
file
P