comtrya_lib/contexts/
env.rs

1use anyhow::Result;
2
3use super::ContextProvider;
4use crate::contexts::Context;
5
6pub struct EnvContextProvider;
7
8impl ContextProvider for EnvContextProvider {
9    fn get_prefix(&self) -> String {
10        String::from("env")
11    }
12
13    fn get_contexts(&self) -> Result<Vec<super::Context>> {
14        let mut contexts = vec![];
15
16        for (key, value) in std::env::vars() {
17            contexts.push(Context::KeyValueContext(key, value.into()));
18        }
19
20        Ok(contexts)
21    }
22}