diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-01-16 00:57:41 -0600 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-01-16 00:57:41 -0600 |
commit | ed778ab2060c6131caf98231a97873d7ea490d5a (patch) | |
tree | bfa6ceca8fe2e209562c1e995c598d80be0e4501 /src/config.rs | |
parent | 54f497163f57dacd8d621a2a3c89e1f06ac370d0 (diff) |
The start of database functionality.
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..14a4c19 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,17 @@ +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<Config> { + 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())) + } +} |