parse_file

Function parse_file 

Source
pub fn parse_file<P: AsRef<Path>>(path: P) -> Result<Value>
Expand description

Parse configuration from a file, auto-detecting format from extension

Reads a configuration file from disk and automatically detects the format based on the file extension (.conf, .toml, .json, .noml).

§Arguments

  • path - Path to the configuration file

§Returns

Returns a Value containing the parsed configuration data.

§Errors

Returns an error if:

  • The file cannot be read (I/O error)
  • The file format cannot be detected
  • The file contains syntax errors
  • Required features are not enabled for the detected format

§Examples

use config_lib::parse_file;

let config = parse_file("app.conf")?;
let port = config.get("server.port").unwrap().as_integer()?;