lingxia 0.9.0

LingXia - Cross-platform LxApp (lightweight application) framework for Android, iOS, and HarmonyOS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::sync::{Arc, OnceLock};

use lingxia_platform::Platform;

static PLATFORM: OnceLock<Arc<Platform>> = OnceLock::new();

pub(crate) fn set_platform(platform: Arc<Platform>) {
    let _ = PLATFORM.set(platform);
}

pub(crate) fn platform() -> crate::Result<Arc<Platform>> {
    PLATFORM
        .get()
        .cloned()
        .ok_or_else(|| crate::Error::internal("LingXia native runtime is not initialized"))
}