Function config::reader::from_file [] [src]

pub fn from_file(path: &Path) -> Result<ConfigConfigError>

Reads a configuration from a UTF-8 file. Errors can be caused by:

  • An error when trying to locate / open the file. This is treated as an I/O error.
  • A syntax error

Errors upon opening the file can happen due to the file not existing, or bad permissions, etc.

Examples

This reads and parses a configuration stored in examples/sample.conf:

use std::path::Path;

use config::reader::from_file;

let parsed = from_file(Path::new("tests/sample.conf"));
assert!(parsed.is_ok());