Skip to main content

ConfigSource

Trait ConfigSource 

Source
pub trait ConfigSource {
    // Required method
    fn toml_value(&self, key: &str) -> Option<&Value>;

    // Provided methods
    fn env_var(&self, suffix: &str) -> Option<String> { ... }
    fn env_name(&self) -> Option<&str> { ... }
}
Expand description

Something a field’s assembly instructions can be checked against: “do you have a TOML-shaped value for this key” and “do you have a string value for an env var with this suffix.” EnvConfig::assemble walks a whole SourceChain of these, in priority order, so more than one kind of fallback source can contribute to the same struct.

Required Methods§

Source

fn toml_value(&self, key: &str) -> Option<&Value>

The raw TOML value stored under key, if this source has one.

Provided Methods§

Source

fn env_var(&self, suffix: &str) -> Option<String>

The raw environment-variable string for a field, if this source has one.

Source

fn env_name(&self) -> Option<&str>

The environment name this source represents, if it represents one at all.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§