Method
new
(source: impl AsRef<Path>)
Source from the content-addressed store, hash-verified
| 107 | |
| 108 | impl Config { |
| 109 | fn new(source: impl AsRef<Path>) -> Result<Self, Box<dyn std::error::Error>> { |
| 110 | let path = source.as_ref(); |
| 111 | if path.exists() { |
| 112 | let content = fs::read_to_string(path)?; |
| 113 | Ok(toml::from_str(&content)?) |
| 114 | } else { |
| 115 | Ok(Config::default()) |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | pub fn load(path: &str) -> &Config { |
| 120 | CONFIG.get_or_init(|| { |
Callers
nothing calls this directly
Tested by
no test coverage detected