23 lines
470 B
Rust
23 lines
470 B
Rust
use serde::Deserialize;
|
|
use std::error::Error;
|
|
use std::fs;
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct ConfigUser {
|
|
pub name: String,
|
|
pub location: String,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct Config {
|
|
pub config_users: Vec<ConfigUser>,
|
|
}
|
|
|
|
const CONFIG_FILENAME: &str = "config.json";
|
|
|
|
pub fn get_config() -> Result<Config, Box<dyn Error>> {
|
|
let data = fs::read_to_string(CONFIG_FILENAME)?;
|
|
|
|
serde_json::from_str(&data).map_err(|e| e.into())
|
|
}
|