You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
866 B
41 lines
866 B
use super::*;
|
|
|
|
//TODO: Use tokio Watcher instead, to allow hotreloading?
|
|
use once_cell::sync::OnceCell;
|
|
|
|
static INSTANCE: OnceCell<Config> = OnceCell::new();
|
|
|
|
/// Set the global config instance.
|
|
/// This can only be done once for the duration of the program's runtime
|
|
pub fn set(conf: Config)
|
|
{
|
|
INSTANCE.set(conf).expect("Failed to set global config state: Already set");
|
|
}
|
|
|
|
/// Get the global config instance.
|
|
/// `set()` must have been previously called or this function panics.
|
|
pub fn get() -> &'static Config
|
|
{
|
|
INSTANCE.get().expect("Global config tried to be accessed before it was set")
|
|
}
|
|
|
|
/// Config for this run
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Config
|
|
{
|
|
/// Name for nanashi
|
|
pub anon_name: String,
|
|
}
|
|
|
|
impl Default for Config
|
|
{
|
|
#[inline]
|
|
fn default() -> Self
|
|
{
|
|
Self {
|
|
anon_name: "Nanashi",
|
|
}
|
|
}
|
|
}
|
|
|