parse_env_value

Function parse_env_value 

Source
fn parse_env_value(s: &str) -> EnvValue
Expand description

Parses a string into an EnvValue, interpreting values that start with env: as environment variable references.

The prefix env: (case-sensitive) is removed and the remainder is trimmed; if the prefix is present the result is EnvValue::Env(var), otherwise the original string is returned as EnvValue::Literal.

§Examples

// env reference
assert_eq!(parse_env_value("env:API_KEY"), EnvValue::Env("API_KEY".to_string()));
// with whitespace after prefix
assert_eq!(parse_env_value("env:  VAR  "), EnvValue::Env("VAR".to_string()));
// literal value
assert_eq!(parse_env_value("plain"), EnvValue::Literal("plain".to_string()));