From 9f3098e80c6b6c87e9bfbfe36239a39e5cafb29f Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Wed, 26 Oct 2022 21:02:31 -0400 Subject: init: add some stories and personas and begin layout out domain --- dichroism/src/config.rs | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 dichroism/src/config.rs (limited to 'dichroism/src/config.rs') diff --git a/dichroism/src/config.rs b/dichroism/src/config.rs deleted file mode 100644 index 2031ecc..0000000 --- a/dichroism/src/config.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::constants::DEFAULT_CONFIG; -use crate::result::Result; -use once_cell::sync::Lazy; -use serde::Deserialize; -use std::env::var; -use std::fs::File; -use std::io::prelude::*; -use std::net::SocketAddr; -use toml::from_str; - -pub static CONFIG_INSTANCE: Lazy = Lazy::new(|| { - Config::from_toml().unwrap_or_else(|e| { - eprintln!("Error parsing config: {}", e.to_string()); - std::process::exit(1); - }) -}); - -#[derive(Debug, Clone, Deserialize)] -pub struct Config { - pub db_url: String, - pub img_root: String, - pub bind_addr: SocketAddr, -} - -impl Config { - pub fn from_toml() -> Result { - let path = var("DICHROISM_CONFIG").unwrap_or_else(|_| String::from(DEFAULT_CONFIG)); - let mut config = String::new(); - File::open(path)?.read_to_string(&mut config)?; - Ok(from_str(&config)?) - } -} -- cgit v1.2.3