GLOBALS, and loading config into it

This commit is contained in:
Mike Dilger committed 2024-02-15 09:22:02 +13:00
1 parent 07be9a2e40
commit ff0c9ca009
2 files changed
+20

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
use crate::config::Config;
use lazy_static::lazy_static;
use tokio::sync::RwLock;
pub struct Globals {
pub config: RwLock<Config>,
}
lazy_static! {
pub static ref GLOBALS: Globals = {
Globals {
config: RwLock::new(Config::default()),
}
};
}
+5
View File
@@ -1,9 +1,11 @@
pub mod config;
pub mod error;
pub mod globals;
use crate::config::Config;
use crate::error::Error;
use crate::globals::GLOBALS;
use std::env;
use std::fs::OpenOptions;
use std::io::Read;
@@ -27,6 +29,9 @@ async fn main() -> Result<(), Error> {
let config: Config = ron::from_str(&contents)?;
log::debug!("Loaded config file.");
// Store config into GLOBALS
*GLOBALS.config.write().await = config;
log::error!("No main yet.");
Ok(())