Skip to main content

AppRuntime

Trait AppRuntime 

Source
pub trait AppRuntime:
    Send
    + Sync
    + MediaInteraction
    + MediaRuntime
    + Network
    + PopupPresenter
    + Device
    + DeviceHardware
    + DeviceSecureStore
    + DocumentInteraction
    + Location
    + UIUpdate
    + UpdateService
    + UserFeedback
    + Wifi
    + 'static {
    // Required methods
    fn read_asset<'a>(
        &'a self,
        path: &str,
    ) -> Result<Box<dyn Read + 'a>, PlatformError>;
    fn asset_dir_iter<'a>(
        &'a self,
        asset_dir: &str,
    ) -> Box<dyn Iterator<Item = Result<AssetFileEntry<'a>, PlatformError>> + 'a>;
    fn app_data_dir(&self) -> PathBuf;
    fn app_cache_dir(&self) -> PathBuf;
    fn get_app_identifier(&self) -> Result<String, PlatformError>;
    fn get_system_locale(&self) -> &str;
    fn show_lxapp(
        &self,
        appid: String,
        path: String,
    ) -> Result<(), PlatformError>;
    fn hide_lxapp(&self, appid: String) -> Result<(), PlatformError>;
    fn navigate(
        &self,
        appid: String,
        path: String,
        animation_type: AnimationType,
    ) -> Result<(), PlatformError>;
    fn launch_with_url(&self, url: String) -> Result<(), PlatformError>;
    fn get_capsule_rect(&self, callback_id: u64) -> Result<(), PlatformError>;

    // Provided method
    fn copy_album_media_to_file(
        &self,
        uri: &str,
        dest_path: &Path,
        kind: MediaKind,
    ) -> Result<(), PlatformError> { ... }
}

Required Methods§

Source

fn read_asset<'a>( &'a self, path: &str, ) -> Result<Box<dyn Read + 'a>, PlatformError>

Reads an asset file as a streaming reader.

Source

fn asset_dir_iter<'a>( &'a self, asset_dir: &str, ) -> Box<dyn Iterator<Item = Result<AssetFileEntry<'a>, PlatformError>> + 'a>

Iterates over files in an asset directory.

Source

fn app_data_dir(&self) -> PathBuf

Returns the app’s data directory path.

Source

fn app_cache_dir(&self) -> PathBuf

Returns the app’s cache directory path.

Source

fn get_app_identifier(&self) -> Result<String, PlatformError>

Obtains the application identifier.

Source

fn get_system_locale(&self) -> &str

Returns the current system locale.

Source

fn show_lxapp(&self, appid: String, path: String) -> Result<(), PlatformError>

Show the UI container for the given LxApp and route.

Source

fn hide_lxapp(&self, appid: String) -> Result<(), PlatformError>

Hide the UI container for the given LxApp (does not destroy its runtime state).

Source

fn navigate( &self, appid: String, path: String, animation_type: AnimationType, ) -> Result<(), PlatformError>

Navigates within the given LxApp using an animation.

Source

fn launch_with_url(&self, url: String) -> Result<(), PlatformError>

Launches the given URL in the host environment.

Source

fn get_capsule_rect(&self, callback_id: u64) -> Result<(), PlatformError>

Gets the capsule button bounding rect in screen coordinates. Returns result via callback with JSON string format: {“width”: 84.5, “height”: 32, “top”: 50, “right”: 375, “bottom”: 82, “left”: 290.5} All values are in pixels, relative to screen top-left corner (0, 0). Note: This only works when the page has showNavigationBar: false (webview is fullscreen).

§Arguments
  • callback_id - The callback ID to invoke with the result
§iOS/macOS

Returns synchronously via callback immediately

§Android/HarmonyOS

Returns asynchronously via callback after querying native UI layer

Provided Methods§

Source

fn copy_album_media_to_file( &self, uri: &str, dest_path: &Path, kind: MediaKind, ) -> Result<(), PlatformError>

Copies media from the system album to a local file.

Implementors§