comtrya_lib/contexts/
variables.rs

1use anyhow::Result;
2
3use crate::{
4    config::Config,
5    contexts::{Context, ContextProvider},
6};
7
8pub struct VariablesContextProvider<'a> {
9    pub config: &'a Config,
10}
11
12impl<'a> ContextProvider for VariablesContextProvider<'a> {
13    fn get_prefix(&self) -> String {
14        String::from("variables")
15    }
16
17    fn get_contexts(&self) -> Result<Vec<super::Context>> {
18        let mut contexts = vec![];
19
20        for (key, value) in self.config.variables.iter() {
21            contexts.push(Context::KeyValueContext(
22                key.to_owned(),
23                value.to_owned().into(),
24            ));
25        }
26
27        Ok(contexts)
28    }
29}