Skip to main content

env_layer

Function env_layer 

Source
pub fn env_layer<F, L>(
    table: &[(&str, &str)],
    lookup: F,
    is_list: L,
) -> Result<Node, ConfigError>
where F: Fn(&str) -> Option<String>, L: Fn(&str) -> bool,
Expand description

The environment layer: one value per variable of table that lookup finds, at the path the table gives it.

table pairs a variable name with a dotted path, the way the runtime’s SETTINGS does. lookup is the environment — std::env::var in a program, a map in a test. An empty value counts as set: FOO= is how an operator clears a list.

A path is_list accepts becomes a sequence, split at commas, so that a drop-in’s +name appends to what the environment set instead of meeting a scalar. An empty value is the empty sequence.

§Errors

ConfigError::Usage when a table path is not a dotted path, which is a defect in the table rather than in the environment.