elif_core/config/
sources.rs

1/// Configuration source information for debugging and hot-reload
2#[derive(Debug, Clone)]
3pub enum ConfigSource {
4    /// Value loaded from environment variable
5    EnvVar(String),
6    /// Default value used
7    Default(String),
8    /// Value loaded from nested configuration
9    Nested,
10    /// Value loaded from file
11    File(String),
12    /// Value provided programmatically
13    Programmatic,
14}
15
16impl ConfigSource {
17    /// Check if source is environment variable
18    pub fn is_env_var(&self) -> bool {
19        matches!(self, ConfigSource::EnvVar(_))
20    }
21    
22    /// Check if source is default value
23    pub fn is_default(&self) -> bool {
24        matches!(self, ConfigSource::Default(_))
25    }
26    
27    /// Check if source is from file
28    pub fn is_file(&self) -> bool {
29        matches!(self, ConfigSource::File(_))
30    }
31    
32    /// Get source description
33    pub fn description(&self) -> String {
34        match self {
35            ConfigSource::EnvVar(var) => format!("Environment variable: {}", var),
36            ConfigSource::Default(value) => format!("Default value: {}", value),
37            ConfigSource::Nested => "Nested configuration".to_string(),
38            ConfigSource::File(path) => format!("Configuration file: {}", path),
39            ConfigSource::Programmatic => "Programmatically set".to_string(),
40        }
41    }
42}
43
44impl std::fmt::Display for ConfigSource {
45    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46        write!(f, "{}", self.description())
47    }
48}