configbuilder-pattern-substitution 0.1.0

configbuilder-pattern: substitution domain, trait contract + reference implementation. No -svc counterpart.
Documentation
use crate::SubstitutionError;

/// Resolves a substitution variable name to its value.
///
/// [`Substituter`] applies this after [`SubstitutionPolicy`] has approved a
/// variable name, decoupling *which names are allowed* from *where their
/// values come from*. The default implementor is [`EnvValueResolver`],
/// backed by `std::env::var`; downstream consumers may supply their own
/// implementation to source values from a secrets backend (Vault, AWS
/// Secrets Manager, etc.) instead of the process environment.
///
/// [`Substituter`]: crate::Substituter
/// [`SubstitutionPolicy`]: crate::SubstitutionPolicy
/// [`EnvValueResolver`]: crate::EnvValueResolver
pub trait ValueResolver: Send + Sync {
    /// Resolve `var_name` to its value.
    ///
    /// `location` identifies the config file and key the placeholder
    /// appeared in, for inclusion in the returned error on failure.
    ///
    /// # Errors
    ///
    /// Returns [`SubstitutionError`] when the variable cannot be resolved
    /// (not found, access denied, backend unavailable, etc.).
    fn resolve(&self, var_name: &str, location: &str) -> Result<String, SubstitutionError>;
}