1use crate::environment::EnvironmentConfig;
2use haste_fhir_operation_error::OperationOutcomeError;
3use std::sync::Arc;
4
5mod environment;
6
7pub trait Config<Key: Into<String>>: Send + Sync {
8 fn get(&self, name: Key) -> Result<String, OperationOutcomeError>;
9 fn set(&self, name: Key, value: String) -> Result<(), OperationOutcomeError>;
10}
11
12pub enum ConfigType {
13 Environment,
14}
15
16impl From<&str> for ConfigType {
17 fn from(value: &str) -> Self {
18 match value {
19 "environment" => ConfigType::Environment,
20 _ => panic!("Unknown config type"),
21 }
22 }
23}
24
25pub fn get_config<Key: Into<String>>(config_type: ConfigType) -> Arc<dyn Config<Key>> {
26 match config_type {
27 ConfigType::Environment => Arc::new(EnvironmentConfig::new().unwrap()),
28 }
29}