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 rt;
32pub mod traits;
33
34#[cfg(target_os = "android")]
35mod android;
36
37#[cfg(any(target_os = "ios", target_os = "macos"))]
38mod apple;
39
40#[cfg(target_env = "ohos")]
41pub mod harmony;
42
43#[cfg(target_os = "windows")]
44pub mod windows;
45
46#[cfg(not(any(
47    target_os = "android",
48    target_os = "ios",
49    target_os = "macos",
50    target_os = "windows",
51    target_env = "ohos"
52)))]
53mod unsupported;
54
55#[cfg(any(target_os = "macos", target_os = "windows"))]
56pub mod desktop;
57
58#[cfg(target_os = "android")]
59pub use android::{
60    CachedClass, Platform, get_android_id, get_api_level, get_system_property,
61    has_telephony_feature, init_cached_class, initialize_jni, read_external_storage_text,
62    write_external_storage_text,
63};
64
65#[cfg(any(target_os = "ios", target_os = "macos"))]
66pub use apple::Platform;
67#[cfg(any(target_os = "ios", target_os = "macos"))]
68pub use apple::apply_staged_macos_update;
69
70#[cfg(target_env = "ohos")]
71pub use harmony::Platform;
72
73#[cfg(target_os = "windows")]
74pub use windows::{
75    Platform, WindowsMediaPreviewCancel, WindowsMediaPreviewOpen, WindowsUrlSurfaceWebTag,
76    WindowsVideoCommandDispatcher, apply_staged_windows_update,
77    register_windows_media_preview_host, register_windows_video_command_dispatcher,
78    set_windows_app_exit_handler, set_windows_managed_surface_toggle_handler,
79    set_windows_managed_surface_visible_handler, set_windows_open_url_handler,
80    set_windows_page_visibility_handler, set_windows_pull_to_refresh_handler,
81    set_windows_surface_closed_handler, set_windows_surface_dispose_handler,
82    set_windows_tray_click_intercept_handler, set_windows_tray_menu_handler,
83    set_windows_ui_update_handler, set_windows_url_surface_handler,
84};
85
86#[cfg(not(any(
87    target_os = "android",
88    target_os = "ios",
89    target_os = "macos",
90    target_os = "windows",
91    target_env = "ohos"
92)))]
93pub use unsupported::Platform;
94
95pub mod error;
96pub use error::*;
97
98pub mod i18n;