use serde::Deserialize; use std::fs; use std::path::Path; #[derive(Debug, Deserialize)] pub struct Config { pub server: ServerConfig, } #[derive(Debug, Deserialize)] pub struct ServerConfig { pub host: String, pub port: u16, } impl Config { pub fn load>(path: P) -> Result> { let contents = fs::read_to_string(path)?; let config: Config = serde_yaml::from_str(&contents)?; Ok(config) } pub fn grpc_addr(&self) -> String { format!("http://{}:{}", self.server.host, self.server.port) } }