spin_variables/
statik.rs

1use std::{collections::HashMap, sync::Arc};
2
3use serde::Deserialize;
4use spin_expressions::{async_trait::async_trait, Key, Provider};
5use spin_factors::anyhow;
6
7/// A [`Provider`] that reads variables from an static map.
8#[derive(Debug, Deserialize, Clone)]
9pub struct StaticVariablesProvider {
10    values: Arc<HashMap<String, String>>,
11}
12
13#[async_trait]
14impl Provider for StaticVariablesProvider {
15    async fn get(&self, key: &Key) -> anyhow::Result<Option<String>> {
16        Ok(self.values.get(key.as_str()).cloned())
17    }
18}