pub fn parse(source: &str, format: Option<&str>) -> Result<Value>
Expand description
Parse configuration from a string, auto-detecting format
This is the main entry point for parsing configuration data. The format is automatically detected based on the content structure and syntax.
§Arguments
source
- Configuration text to parseformat
- Optional format hint (auto-detected if None)
§Returns
Returns a Value
containing the parsed configuration data.
§Examples
use config_lib::parse;
let config = parse(r#"
app_name = "my-service"
port = 8080
debug = true
[database]
host = "localhost"
max_connections = 100
"#, None)?;
assert_eq!(config.get("app_name").unwrap().as_string().unwrap(), "my-service");
assert_eq!(config.get("database.host").unwrap().as_string().unwrap(), "localhost");