use std::net::SocketAddr; use std::path::{Path, PathBuf}; use cursive::reexports::ahash::HashSet; use eyre::Context; use tap::Pipe; #[derive(serde::Deserialize)] pub struct Config { pub web_socket: SocketAddr, pub web_base: String, pub cookie_domain: Option, pub admin_socket: PathBuf, pub handoffs: HashSet, pub data: PathBuf, } impl Config { pub fn load(path: &Path) -> eyre::Result { let mut config: Config = path .pipe(std::fs::read_to_string) .wrap_err("reading config file")? .as_str() .pipe(toml::from_str) .wrap_err("parsing config file")?; if config.web_base.ends_with('/') { config.web_base = config.web_base.trim_end_matches('/').to_string(); } Ok(config) } }