use serde_derive::{Deserialize, Serialize}; use std::net::IpAddr; use std::{error::Error, fs}; use toml; #[derive(Serialize, Deserialize, Debug)] pub struct Config { pub client: Clients, pub port: Option, pub backend: Option, } #[derive(Serialize, Deserialize, Debug)] pub struct Clients { pub left: Option, pub right: Option, pub top: Option, pub bottom: Option, } #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] pub struct Client { pub host_name: Option, pub ip: Option, pub port: Option, } impl Config { pub fn new(path: &str) -> Result> { let config = fs::read_to_string(path)?; Ok(toml::from_str::<_>(&config)?) } }