Skip to main content

lingxia_platform/
lib.rs

1//! LingXia Platform
2//!
3//! This crate provides the platform-specific implementation for LingXia.
4
5use std::io::Read;
6
7/// Asset file entry with reader for streaming content
8pub struct AssetFileEntry<'a> {
9    pub path: String,
10    pub reader: Box<dyn Read + 'a>,
11}
12
13/// Device information
14#[derive(Debug, Clone)]
15pub struct DeviceInfo {
16    pub brand: String,
17    pub model: String,
18    pub market_name: String,
19    pub os_name: String,
20    pub os_version: String,
21}
22
23/// Screen information reported in logical pixels (dp/pt) and scale factor
24#[derive(Debug, Clone, serde::Serialize)]
25pub struct ScreenInfo {
26    pub width: f64,
27    pub height: f64,
28    pub scale: f64,
29}
30
31pub(crate) mod bg_runtime;
32pub mod traits;
33
34/// Initialize the platform layer with a tokio runtime handle.
35pub fn init(handle: tokio::runtime::Handle) {
36    bg_runtime::set_handle(handle);
37}
38
39#[cfg(target_os = "android")]
40mod android;
41
42#[cfg(any(target_os = "ios", target_os = "macos"))]
43mod apple;
44
45#[cfg(target_env = "ohos")]
46pub mod harmony;
47
48#[cfg(any(target_os = "macos", target_os = "windows"))]
49pub mod desktop;
50
51#[cfg(target_os = "android")]
52pub use android::{
53    CachedClass, Platform, get_android_id, get_api_level, has_telephony_feature, init_cached_class,
54    read_external_storage_text, write_external_storage_text,
55};
56
57#[cfg(any(target_os = "ios", target_os = "macos"))]
58pub use apple::Platform;
59
60#[cfg(target_env = "ohos")]
61pub use harmony::Platform;
62
63pub mod error;
64pub use error::*;