Newer
Older
use std::{
collections::{HashMap, HashSet},
fs,
};
#[derive(Deserialize)]
pub struct LlamaConfig {
pub(crate) address: String,
#[serde(default)]
pub(crate) channels: HashSet<u64>,
#[derive(Deserialize)]
pub struct Config {
pub(crate) token: String,
}
pub fn get_conf() -> Config {
let file_contents = read_conf_file();
match toml::from_str(&file_contents) {
Ok(x) => x,
Err(x) => {
panic!("Error parsing config file: {}", x);
}
}
}
fn read_conf_file() -> String {
let filenames = ["config.toml", "/etc/cat_disruptor_6500/config.toml"];
for filename in filenames.iter() {
if let Ok(x) = fs::read_to_string(filename) {
return x;
}
}
panic!("Could not open config file");
}