mini_config/
lib.rs

1pub mod arc;
2
3use std::collections::HashMap;
4use std::sync::{Mutex, Once};
5
6static mut MY_HASHMAP: Option<Mutex<HashMap<&'static str, &'static str>>> = None;
7static INIT: Once = Once::new();
8
9pub fn init_memory() {
10    let hashmap = HashMap::<&str, &str>::new();
11    let mutex = Mutex::new(hashmap);
12    unsafe {
13        MY_HASHMAP = Some(mutex);
14    }
15}
16
17pub fn get_value(key: &str) -> Option<&'static str> {
18    INIT.call_once(init_memory);
19    unsafe {
20        MY_HASHMAP
21            .as_ref()
22            .unwrap()
23            .lock()
24            .unwrap()
25            .get(key)
26            .map(|&s| s)
27    }
28}
29
30pub fn set_value(key: &'static str, value: &'static str) {
31    INIT.call_once(init_memory);
32    unsafe {
33        MY_HASHMAP
34            .as_ref()
35            .unwrap()
36            .lock()
37            .unwrap()
38            .insert(key, value);
39    }
40}
41
42#[cfg(feature = "mini-config-derive")]
43#[allow(unused_imports)]
44#[macro_use]
45extern crate mini_config_derive;
46#[cfg(feature = "mini-config-derive")]
47#[doc(hidden)]
48pub use mini_config_derive::*;
49
50#[allow(dead_code)]
51fn main() {}