1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use std::path::PathBuf;
#[derive(Debug, Deserialize, Configure)]
#[serde(default)]
pub struct Config {
pub configuration_path: PathBuf,
pub runtime_info_path: PathBuf,
}
impl Default for Config {
fn default() -> Self {
Config {
configuration_path: PathBuf::from("/boot/xmz-server.toml"),
runtime_info_path: PathBuf::from("/var/cache/xmz-server/status"),
}
}
}
impl Config {
pub fn runtime_info_available(&self) -> bool {
self.runtime_info_path.exists()
}
pub fn config_file_available(&self) -> bool {
self.configuration_path.exists()
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn runtime_info_available() {
let cfg = Config::default();
assert_eq!(cfg.runtime_info_available(), false);
}
#[test]
fn config_file_available() {
let cfg = Config::default();
assert_eq!(cfg.config_file_available(), false);
}
}