1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
pub use config::ConfigError; use serde::Deserialize; #[derive(Deserialize, Debug)] pub struct Config { pub cf: String, pub password: String, } impl Config { pub fn from_env() -> Result<Self, ConfigError> { let mut cfg = config::Config::new(); cfg.merge(config::Environment::new())?; cfg.try_into() } }