Skip to main content

ValueResolver

Trait ValueResolver 

Source
pub trait ValueResolver: Send + Sync {
    // Required method
    fn resolve(
        &self,
        var_name: &str,
        location: &str,
    ) -> Result<String, SubstitutionError>;
}
Expand description

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.

Required Methods§

Source

fn resolve( &self, var_name: &str, location: &str, ) -> Result<String, SubstitutionError>

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.).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§