hocon/adapters/
properties.rs1use super::{config_from_object, AdapterError};
4use crate::properties::properties_to_hocon;
5use crate::Config;
6
7pub fn parse(input: &str, origin: Option<&str>) -> Result<Config, AdapterError> {
13 let value = properties_to_hocon(super::strip_bom(input)).map_err(AdapterError::new)?;
14 Ok(config_from_object(value, origin))
15}
16
17pub fn parse_file(path: impl AsRef<std::path::Path>) -> Result<Config, AdapterError> {
19 let path = path.as_ref();
20 let text = std::fs::read_to_string(path)
21 .map_err(|e| AdapterError::new(format!("properties: {}: {e}", path.display())))?;
22 parse(&text, Some(&path.display().to_string()))
23}