(&self)
| 212 | |
| 213 | impl StringKey<'_> { |
| 214 | pub fn get_value(&self) -> String { |
| 215 | let config = get_config().unwrap_or_default(); |
| 216 | let keys = self.0.to_owned(); |
| 217 | let default_value = self.1.to_owned(); |
| 218 | let mut result; |
| 219 | for key in keys { |
| 220 | if config.contains_key(key) { |
| 221 | result = config[key].as_str().unwrap().to_string() |
| 222 | } else { |
| 223 | result = env::var(get_env_name(key)).unwrap_or_default() |
| 224 | } |
| 225 | if key.eq(CACHE_PATH_KEY) { |
| 226 | // The configuration key for the cache path ("cache-path") is special because |
| 227 | // the rest of the configuration values depend on this value (since the |
| 228 | // configuration file is stored in the cache path). Therefore, this value needs |
| 229 | // to be discovered in the first place and stored globally (on CACHE_PATH) |
| 230 | return check_cache_path(result, default_value); |
| 231 | } |
| 232 | if !result.is_empty() { |
| 233 | return result; |
| 234 | } |
| 235 | } |
| 236 | default_value |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | pub struct IntegerKey<'a>(pub &'a str, pub u64); |
no test coverage detected