Crate germinate[][src]

Expand description

This crate provides a method of injecting variables from multiple external sources into a template string. Sources can be anything as long as they implement the Loader trait which handles the loading of the variables in a standard way.


  • default - ["aws"]
  • aws - Enable the AWS value sources


Built In

These are the currently implemented sources and their associated template keys

AWS EC2 Instance Tagsawsec2tagawsLoad the value of AWS EC2 Instance Tags by their key
AWS EC2 Metadata Serviceawsec2metadataawsLoad a value from the AWS EC2 Metadata Service by it’s path
AWS SSM ParameterawsssmawsLoad a value from the AWS SSM Parameter Store by it’s name. LIMITATION when running on an EC2 instance, the parameter must be in the same region as the instance
Environment Variablesenv-Load the value of an environment variable


let mut seed = Seed::new("Hi %env:NAME%!");
let output = seed.germinate().await?;

assert_eq!("Hi John!", output);

Custom Sources

You can also include your own sources using the Seed::add_custom_loader method. The only requirement is that the custom loader must implement the Loader trait


let mut seed = Seed::new("Hi %name:name%");

// Add a custom loader for the name key. This is the loader that will be used whenever
// germinate finds %name:...% in the template string
seed.add_custom_loader("name".to_string(), Box::new(NameLoader {}));

let output = seed.germinate().await?;

assert_eq!("Hi John", output);


A Seed is responsible for parsing the template string, loading the values, and optionally making the replacements via the germinate method


A type implementing the Loader trait can be used to load a value from a store by it’s key