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
35
36
37
38
mod common;
pub mod data;
pub mod error;
pub mod media;
pub mod peer;
pub mod prelude;
use std::sync::Once;
static mut BASE_URL: String = String::new();
static INIT: Once = Once::new();
static INIT_CHECK: Once = Once::new();
pub fn initialize(base_url: impl Into<String>) {
unsafe {
INIT.call_once(|| {
BASE_URL = base_url.into();
});
}
}
pub(crate) fn base_url() -> &'static str {
unsafe {
INIT_CHECK.call_once(|| {
if BASE_URL.len() == 0 {
panic!("not initialized");
}
});
&BASE_URL
}
}