mirror of
https://github.com/mikedilger/chorus.git
synced 2026-06-02 07:02:09 +00:00
GLOBALS, and loading config into it
This commit is contained in:
parent
07be9a2e40
commit
ff0c9ca009
15
src/globals.rs
Normal file
15
src/globals.rs
Normal 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()),
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -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(())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user