Function subst::substitute_bytes

source ·
pub fn substitute_bytes<'a, M>(
    source: &[u8],
    variables: &'a M
) -> Result<Vec<u8>, Error>where
    M: VariableMap<'a> + ?Sized,
    M::Value: AsRef<[u8]>,
Expand description

Substitute variables in a byte string.

Variables have the form $NAME, ${NAME} or ${NAME:default}. A variable name can only consist of ASCII letters, digits and underscores. They are allowed to start with numbers.

You can escape dollar signs, backslashes, colons and braces with a backslash.

You can pass either a HashMap, BTreeMap as the variables parameter. The maps must have &str or String keys, and the values must be [AsRef<[u8]>]. On Unix platforms, you can also use EnvBytes.