SVI
string variable interpolator
this crate contains a function that interpolates variables in a hashmap into an input string, producing both the resulting string, plus a vec of 'replacers' to make output safe to store or print without compromising secrets.
variables can be matched with either [[variable_name]] (DoubleBrackets) or {{variable_name}} (DoubleCurlyBrackets).
Usage
let variables: =
.into_iter
.map
.collect;
let to_fmt = "mongodb://[[mongo_username]]:[[mongo_password]]@127.0.0.1:27017";
let = interpolate_variables?;
println!; // prints 'mongodb://root:mng233985725@127.0.0.1:27017'
// makes output involving replaced variables safe to print / store
let readable = replace_in_string;
println!; // prints 'mongodb://<mongo_username>:<mongo_password>@127.0.0.1:27017'
Escaping Interpolation
let variables = new;
let to_fmt = "the interpolator will escape interpolation with 3 openers: [[[not a variable]]]";
let = interpolate_variables?;
println!; // prints 'the interpolator will escape interpolation with 3 openers: [[not a variable]]'