lingxia_platform/traits/
app_runtime.rs1use std::io::Read;
2use std::path::{Path, PathBuf};
3
4use crate::AssetFileEntry;
5use crate::error::PlatformError;
6
7use super::device::{Device, DeviceHardware, DeviceSecureStore};
8use super::document::DocumentInteraction;
9use super::location::Location;
10use super::media_interaction::{MediaInteraction, MediaKind};
11use super::media_runtime::MediaRuntime;
12use super::ui::{PopupPresenter, UIUpdate, UserFeedback};
13use super::update::UpdateService;
14use super::wifi::Wifi;
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum AnimationType {
18 None = 0,
19 Forward = 1,
20 Backward = 2,
21}
22
23impl From<i32> for AnimationType {
24 fn from(value: i32) -> Self {
25 match value {
26 1 => AnimationType::Forward,
27 2 => AnimationType::Backward,
28 _ => AnimationType::None,
29 }
30 }
31}
32
33pub trait AppRuntime:
34 Send
35 + Sync
36 + MediaInteraction
37 + MediaRuntime
38 + PopupPresenter
39 + Device
40 + DeviceHardware
41 + DeviceSecureStore
42 + DocumentInteraction
43 + Location
44 + UIUpdate
45 + UpdateService
46 + UserFeedback
47 + Wifi
48 + 'static
49{
50 fn read_asset<'a>(&'a self, path: &str) -> Result<Box<dyn Read + 'a>, PlatformError>;
52
53 fn asset_dir_iter<'a>(
55 &'a self,
56 asset_dir: &str,
57 ) -> Box<dyn Iterator<Item = Result<AssetFileEntry<'a>, PlatformError>> + 'a>;
58
59 fn app_data_dir(&self) -> PathBuf;
61
62 fn app_cache_dir(&self) -> PathBuf;
64
65 fn get_app_identifier(&self) -> Result<String, PlatformError>;
67
68 fn copy_album_media_to_file(
70 &self,
71 uri: &str,
72 dest_path: &Path,
73 kind: MediaKind,
74 ) -> Result<(), PlatformError> {
75 MediaRuntime::copy_album_media_to_file(self, uri, dest_path, kind)
76 }
77
78 fn get_system_locale(&self) -> &str;
80
81 fn show_lxapp(&self, appid: String, path: String) -> Result<(), PlatformError>;
83
84 fn hide_lxapp(&self, appid: String) -> Result<(), PlatformError>;
86
87 fn navigate(
89 &self,
90 appid: String,
91 path: String,
92 animation_type: AnimationType,
93 ) -> Result<(), PlatformError>;
94
95 fn launch_with_url(&self, url: String) -> Result<(), PlatformError>;
97
98 fn get_capsule_rect(&self, callback_id: u64) -> Result<(), PlatformError>;
112}