use crate::ConfigError;
/// Load typed TOML sections from a layered config chain.
///
/// Implementations merge config directories in order (later wins) and return
/// `Ok(T::default())` when the requested key is absent from every source.
/// Environment variable substitution (`{{VAR_NAME}}` syntax) is optionally supported
/// when the loader was created with a `SubstitutionPolicy`.
///
/// The reference implementation is [`DefaultLoader`]. This trait is in scope for
/// generic code that accepts any loader.
///
/// [`DefaultLoader`]: crate::DefaultLoader
pub trait Loader {
/// Load the section at `key` (dotted path, e.g. `"outer.inner"`) from all
/// configured directories, merging with last-wins semantics.
///
/// Returns `Ok(T::default())` when the key is absent from every file.
/// If the loader was created with a substitution policy, `{{VAR_NAME}}`
/// placeholders are substituted with environment variable values after loading.
fn load_section<T>(&self, key: &str) -> Result<T, ConfigError>
where
T: serde::de::DeserializeOwned + Default;
/// Validate that all configured directories are accessible.
///
/// Non-existent paths are permitted (skipped at load time); a path that
/// exists but is not a directory is a hard error.
fn validate(&self) -> Result<(), ConfigError>;
}