diff options
author | Cara Salter <cara@devcara.com> | 2022-08-24 13:15:31 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2022-08-24 13:15:31 -0400 |
commit | 9de84e3fbae0f2893e9c4f1425afa06899959bf7 (patch) | |
tree | f96d33d881954edc9b03df0bc821fb35eb59c577 /src/config.rs | |
parent | 4b616447715b8129ae322341959e1c2bfabbd10e (diff) | |
download | nccd-9de84e3fbae0f2893e9c4f1425afa06899959bf7.tar.gz nccd-9de84e3fbae0f2893e9c4f1425afa06899959bf7.zip |
flaskify
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/src/config.rs b/src/config.rs deleted file mode 100644 index c153085..0000000 --- a/src/config.rs +++ /dev/null @@ -1,54 +0,0 @@ -use serde::Deserialize; -use tracing::error; - -use crate::errors::ServiceError; -use std::fs; -use std::str; - -#[derive(Deserialize)] -pub struct Config { - pub server: ServerConfig, - pub database: DbConfig, - pub email: EmailConfig, -} - -#[derive(Deserialize)] -pub struct ServerConfig { - pub bind_addr: String, - pub admin_email: String -} - -#[derive(Deserialize, Clone)] -pub struct DbConfig { - pub postgres_url: String, - pub max_connections: u32, -} - -#[derive(Deserialize)] -pub struct EmailConfig { - pub smtp_server: String, - pub smtp_port: u16, - pub smtp_tls: bool, - pub smtp_starttls: bool, - pub smtp_username: Option<String>, - pub smtp_password: Option<String>, - pub email_from: String, - pub email_helo: String, -} - -impl Config { - pub fn init(path: String) -> Result<Config, ServiceError> { - if let Ok(c) = fs::read(path) { - if c.len() == 0 { - error!("Config file empty."); - return Err(ServiceError::MissingConfig); - } else { - let config: Config = toml::from_str(str::from_utf8(&c).unwrap())?; - return Ok(config); - } - } else { - error!("Unable to read from config file."); - return Err(ServiceError::MissingConfig); - } - } -} |