MCPcopy Create free account
hub / github.com/Firstyear/opensuse-proxy-cache / parse

Method parse

opensuse-proxy-cache/src/config.rs:32–51  ·  view source on GitHub ↗
(config_path: P)

Source from the content-addressed store, hash-verified

30
31impl 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected