pub fn parse(source: &str, format: Option<&str>) -> Result<Value>
Expand description
Parse configuration from a string with optional format hint
This is the primary entry point for parsing configuration data from strings. Automatically detects format if not specified.
§Arguments
source
- The configuration data as a stringformat
- Optional format hint (“conf”, “toml”, “json”, “noml”)
§Returns
Returns a Value
containing the parsed configuration data.
§Errors
Returns an error if:
- The input format is unknown or unsupported
- The input contains syntax errors
- Required features are not enabled for the detected format
§Examples
use config_lib::parse;
let config = parse("port = 8080\nname = \"MyApp\"", Some("conf"))?;
let port = config.get("port").unwrap().as_integer()?;