use std::{fs, path::Path}; use anyhow::Result; use serde::Deserialize; /// The main configuration. #[derive(Debug, Clone, Deserialize, Default)] pub struct Config { /// Flag indicating whether logs should be uploaded or not. pub upload: bool, /// Flag indicating whether logs with an unknown boss should be uploaded. #[serde(default)] pub upload_unknown: bool, /// Option Discord information for bot postings. pub discord: Option, } /// Configuration pertaining to the Discord posting. #[derive(Debug, Clone, Deserialize)] pub struct Discord { /// Auth token for the Discord bot. pub auth_token: String, /// Channel ID in which logs should be posted. pub channel_id: u64, } /// Attempt to load the configuration from the given file. pub fn load>(path: P) -> Result { let content = fs::read(path)?; Ok(toml::from_slice(&content)?) }