diff options
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..e4203de --- /dev/null +++ b/src/config.rs @@ -0,0 +1,31 @@ +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<Discord>, +} + +/// 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<P: AsRef<Path>>(path: P) -> Result<Config> { + let content = fs::read(path)?; + Ok(toml::from_slice(&content)?) +} |