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>;
15 fn set(&self, name: Key, value: String) -> Result<(), OperationOutcomeError>;
21}
22
23#[derive(Clone, Copy)]
24pub enum ConfigType {
25 Environment,
26}
27
28impl From<&str> for ConfigType {
29 fn from(value: &str) -> Self {
30 match value {
31 "environment" => ConfigType::Environment,
32 _ => panic!("Unknown config type"),
33 }
34 }
35}
36
37#[must_use]
38pub fn get_config<Key: Into<String>>(config_type: ConfigType) -> Arc<dyn Config<Key>> {
39 match config_type {
40 ConfigType::Environment => Arc::new(EnvironmentConfig::new(&[".env", ".env.development"])),
41 }
42}