use crate::value::HoconValue;
use crate::Config;
#[cfg(feature = "adapters-env")]
pub mod env;
#[cfg(feature = "adapters-jsonc")]
pub mod jsonc;
#[cfg(feature = "adapters-properties")]
pub mod properties;
#[cfg(feature = "adapters-toml")]
pub mod toml;
#[cfg(feature = "adapters-yaml")]
pub mod yaml;
pub(crate) fn config_from_object(root: HoconValue, origin: Option<&str>) -> Config {
match root {
HoconValue::Object(fields) => Config::new_with_meta(fields, origin.map(|s| s.to_owned())),
_ => unreachable!("callers pass an object"),
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AdapterError {
pub message: String,
}
impl std::fmt::Display for AdapterError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.message)
}
}
impl std::error::Error for AdapterError {}
impl AdapterError {
pub(crate) fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}