mxl_base/
about.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use once_cell::sync::OnceCell;

#[derive(Debug)]
pub struct About {
    pub qualifier: &'static str,
    pub organization: &'static str,
    pub app_name: &'static str,
    pub binary_name: &'static str,
    pub version: &'static str,
}

static ABOUT_REGISTER: OnceCell<About> = OnceCell::new();

pub(crate) fn about_init(
    qualifier: &'static str,
    organization: &'static str,
    app_name: &'static str,
    binary_name: &'static str,
    version: &'static str,
) {
    ABOUT_REGISTER
        .set(About {
            qualifier,
            organization,
            app_name,
            binary_name,
            version,
        })
        .expect("Already initialized");
}

pub fn about() -> &'static About {
    ABOUT_REGISTER.get().expect("Initialize first")
}