(config_path: P)
| 30 | |
| 31 | impl Config { |
| 32 | pub fn parse<P: AsRef<Path>>(config_path: P) -> Option<Config> { |
| 33 | if !config_path.as_ref().exists() { |
| 34 | return None; |
| 35 | } |
| 36 | |
| 37 | let mut f = File::open(config_path.as_ref()) |
| 38 | .inspect_err(|err| error!(?err)) |
| 39 | .expect("unable to open file"); |
| 40 | |
| 41 | let mut contents = String::new(); |
| 42 | f.read_to_string(&mut contents) |
| 43 | .inspect_err(|err| error!(?err)) |
| 44 | .expect("unable to open file"); |
| 45 | |
| 46 | let config: Config = toml::from_str(contents.as_str()) |
| 47 | .inspect_err(|err| error!(?err)) |
| 48 | .expect("unable to open file"); |
| 49 | |
| 50 | Some(config) |
| 51 | } |
| 52 | } |
nothing calls this directly
no outgoing calls
no test coverage detected