use anyhow::{Context, Result}; use serde::Deserialize; use std::{fs, path::Path}; #[derive(Debug, Deserialize)] pub struct Config { pub database_url: String, pub discord_token: String, } impl Config { pub fn read_from_file(path: &Path) -> Result { let config_str = fs::read_to_string(path) .with_context(|| format!("failed to read {}", path.display()))?; toml::from_str(&config_str).with_context(|| format!("failed to parse {}", path.display())) } }