[−][src]Function bar_config::config_file
pub fn config_file(name: &str) -> Result<File, IOError>
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:
Feature | Extension |
---|---|
default | yml |
toml-fmt | toml |
json-fmt | json |
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);