elif_core/config/
sources.rs1#[derive(Debug, Clone)]
3pub enum ConfigSource {
4 EnvVar(String),
6 Default(String),
8 Nested,
10 File(String),
12 Programmatic,
14}
15
16impl ConfigSource {
17 pub fn is_env_var(&self) -> bool {
19 matches!(self, ConfigSource::EnvVar(_))
20 }
21
22 pub fn is_default(&self) -> bool {
24 matches!(self, ConfigSource::Default(_))
25 }
26
27 pub fn is_file(&self) -> bool {
29 matches!(self, ConfigSource::File(_))
30 }
31
32 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}