config_file

Function config_file 

Source
pub fn config_file(name: &str) -> Result<File, Error>
Expand description

Find the configuration file.

This looks for the configuration file of the bar in a predefined list of directories. The name parameter is used for the configuration file name and the extension is based on the enabled features.

The directories are used in the following order:

~/.config/name.ext
~/.name.ext
/etc/name/name.ext

The file endings map to the specified library features:

FeatureExtension
defaultyml
toml-fmttoml
json-fmtjson

§Errors

This method will fail if the configuration file cannot be opened. If there was no file present in any of the directories, the io::ErrorKind::NotFound error will be returned.

§Examples

use bar_config::config_file;
use std::io::ErrorKind;

let file_result = config_file("mybar");
assert_eq!(file_result.err().unwrap().kind(), ErrorKind::NotFound);