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::network::Network;
13use super::ui::{PopupPresenter, UIUpdate, UserFeedback};
14use super::update::UpdateService;
15use super::wifi::Wifi;
16
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub enum AnimationType {
19 None = 0,
20 Forward = 1,
21 Backward = 2,
22}
23
24impl From<i32> for AnimationType {
25 fn from(value: i32) -> Self {
26 match value {
27 1 => AnimationType::Forward,
28 2 => AnimationType::Backward,
29 _ => AnimationType::None,
30 }
31 }
32}
33
34pub trait AppRuntime:
35 Send
36 + Sync
37 + MediaInteraction
38 + MediaRuntime
39 + Network
40 + PopupPresenter
41 + Device
42 + DeviceHardware
43 + DeviceSecureStore
44 + DocumentInteraction
45 + Location
46 + UIUpdate
47 + UpdateService
48 + UserFeedback
49 + Wifi
50 + 'static
51{
52 fn read_asset<'a>(&'a self, path: &str) -> Result<Box<dyn Read + 'a>, PlatformError>;
54
55 fn asset_dir_iter<'a>(
57 &'a self,
58 asset_dir: &str,
59 ) -> Box<dyn Iterator<Item = Result<AssetFileEntry<'a>, PlatformError>> + 'a>;
60
61 fn app_data_dir(&self) -> PathBuf;
63
64 fn app_cache_dir(&self) -> PathBuf;
66
67 fn get_app_identifier(&self) -> Result<String, PlatformError>;
69
70 fn copy_album_media_to_file(
72 &self,
73 uri: &str,
74 dest_path: &Path,
75 kind: MediaKind,
76 ) -> Result<(), PlatformError> {
77 MediaRuntime::copy_album_media_to_file(self, uri, dest_path, kind)
78 }
79
80 fn get_system_locale(&self) -> &str;
82
83 fn show_lxapp(&self, appid: String, path: String) -> Result<(), PlatformError>;
85
86 fn hide_lxapp(&self, appid: String) -> Result<(), PlatformError>;
88
89 fn navigate(
91 &self,
92 appid: String,
93 path: String,
94 animation_type: AnimationType,
95 ) -> Result<(), PlatformError>;
96
97 fn launch_with_url(&self, url: String) -> Result<(), PlatformError>;
99
100 fn get_capsule_rect(&self, callback_id: u64) -> Result<(), PlatformError>;
114}