Skip to main content

MiniAppPlatform

Struct MiniAppPlatform 

Source
pub struct MiniAppPlatform { /* private fields */ }
Expand description

Unified Rust/WASM Mini-Program host adapter abstracting WeChat, Alipay, Douyin, Baidu, QQ, Kuaishou, and HarmonyOS Atomic Service.

Implementations§

Source§

impl MiniAppPlatform

Vendor constructors, touch/IME/lifecycle translation, and outbound bridge queue helpers for MiniAppPlatform.

Source

pub fn for_vendor(vendor: MiniAppVendor) -> Self

Creates a MiniAppPlatform configured for vendor with capsule-cleared safe-area insets.

§Arguments
  • MiniAppVendor - Target Mini-Program host vendor.
§Returns
  • Self - Configured Mini-Program backend.
Source

pub fn from_system_info(system_info: MiniAppSystemInfo) -> Self

Creates a MiniAppPlatform from concrete host MiniAppSystemInfo.

§Arguments
  • MiniAppSystemInfo - Runtime system info reported by the host shell.
§Returns
  • Self - Configured Mini-Program backend.
Source

pub fn primary_window_id(&self) -> Option<WindowId>

Returns the primary Mini-Program canvas window identifier, if created.

§Arguments
  • &Self - Mini-program platform reference.
§Returns
  • Option<WindowId> - Primary canvas window handle.
Source

pub fn drain_host_commands(&mut self) -> Vec<MiniAppHostCommand>

Drains all queued outbound host bridge commands for execution by the thin JS/ArkTS shell.

§Arguments
  • &Self - Mutable Mini-program platform.
§Returns
  • Vec<MiniAppHostCommand> - Ordered host commands.
Source

pub fn update_system_info(&mut self, info: MiniAppSystemInfo)

Updates host MiniAppSystemInfo (e.g. after orientation change or capsule query) and emits SafeAreaChanged.

§Arguments
  • &Self - Mutable Mini-program platform.
  • MiniAppSystemInfo - Updated host system info.
Source

pub fn handle_touch( &mut self, action: i32, touches: &[(i32, f32, f32)], ) -> Vec<WindowEvent>

Translates Mini-Program <canvas> touch callbacks (touchstart/touchmove/touchend/touchcancel) into EUV pointer events.

§Arguments
  • &Self - Mutable Mini-program platform.
  • i32 - Normalized action (ANDROID_ACTION_DOWN / MOVE / UP / CANCEL).
  • &[(i32, f32, f32)] - Active touch contact tuples (identifier, logical_x, logical_y).
§Returns
  • Vec<WindowEvent> - Normalized pointer events also enqueued for poll_events().
Source

pub fn handle_ime_input(&mut self, text: String, confirmed: bool)

Dispatches UTF-8 text input received from a hidden Mini-Program <input> or onKeyboardInput bridge.

§Arguments
  • &Self - Mutable Mini-program platform.
  • String - Committed UTF-8 text.
  • bool - When true, also emits KeyCode::Enter confirmation.
Source

pub fn handle_lifecycle_hook( &mut self, hook: MiniAppLifecycleHook, ) -> Vec<WindowEvent>

Translates Mini-Program onLaunch / onShow / onHide / onUnload and system hooks into canonical EUV SystemEvents.

§Arguments
  • &Self - Mutable Mini-program platform.
  • MiniAppLifecycleHook - Vendor-neutral lifecycle hook payload.
§Returns
  • Vec<WindowEvent> - Normalized events also enqueued for poll_events().
Source§

impl MiniAppPlatform

Unified host-channel capability and visual-equivalence queries for MiniAppPlatform.

Source

pub fn host_channel_capabilities(&self) -> HostChannelCapabilities

Returns the truthful HostChannelCapabilities declared by this Mini-Program host.

A Canvas2d-only host locks single-channel mode (supported_channels.len() == 1) and NEVER probes WebGL; off-device/simulated profiles ALWAYS set simulated_profile = true and direct_gpu_verified_on_device = false.

§Returns
  • HostChannelCapabilities - Declared MiniApp channels, visual gate, and honesty flags.
Source

pub fn select_render_channel( &self, requested: Option<HostRenderChannel>, ) -> HostChannelSelection

Resolves the MiniApp rendering channel under unified visual-equivalence and single-channel non-probing rules.

§Arguments
  • Option<HostRenderChannel> - Optional requested channel.
§Returns
  • HostChannelSelection - Resolved channel decision.
Source§

impl MiniAppPlatform

Source

pub fn get_system_info(&self) -> &MiniAppSystemInfo

Source

pub fn get_mut_system_info(&mut self) -> &mut MiniAppSystemInfo

Source

pub fn set_system_info(&mut self, val: MiniAppSystemInfo) -> &mut Self

Source

pub fn get_resolved_safe_area(&self) -> SafeAreaInsets

Source

pub fn get_mut_resolved_safe_area(&mut self) -> &mut SafeAreaInsets

Source

pub fn set_resolved_safe_area(&mut self, val: SafeAreaInsets) -> &mut Self

Source

pub fn get_mut_primary_window(&mut self) -> &mut Option<WindowId>

Source

pub fn set_primary_window(&mut self, val: Option<WindowId>) -> &mut Self

Source

pub fn get_windows(&self) -> &HashMap<WindowId, MiniAppWindowRecord>

Source

pub fn get_mut_windows(&mut self) -> &mut HashMap<WindowId, MiniAppWindowRecord>

Source

pub fn set_windows( &mut self, val: HashMap<WindowId, MiniAppWindowRecord>, ) -> &mut Self

Source

pub fn get_touch_tracker(&self) -> &TouchPointerTracker

Source

pub fn get_mut_touch_tracker(&mut self) -> &mut TouchPointerTracker

Source

pub fn set_touch_tracker(&mut self, val: TouchPointerTracker) -> &mut Self

Source

pub fn get_pending_events(&self) -> &Vec<WindowEvent>

Source

pub fn get_mut_pending_events(&mut self) -> &mut Vec<WindowEvent>

Source

pub fn set_pending_events(&mut self, val: Vec<WindowEvent>) -> &mut Self

Source

pub fn get_outbound_commands(&self) -> &Vec<MiniAppHostCommand>

Source

pub fn get_mut_outbound_commands(&mut self) -> &mut Vec<MiniAppHostCommand>

Source

pub fn set_outbound_commands( &mut self, val: Vec<MiniAppHostCommand>, ) -> &mut Self

Source

pub fn get_storage(&self) -> &HashMap<String, String>

Source

pub fn get_mut_storage(&mut self) -> &mut HashMap<String, String>

Source

pub fn set_storage(&mut self, val: HashMap<String, String>) -> &mut Self

Source

pub fn get_route_stack(&self) -> &Vec<String>

Source

pub fn get_mut_route_stack(&mut self) -> &mut Vec<String>

Source

pub fn set_route_stack(&mut self, val: Vec<String>) -> &mut Self

Source

pub fn get_mut_clipboard(&mut self) -> &mut Option<String>

Source

pub fn set_clipboard(&mut self, val: Option<String>) -> &mut Self

Source

pub fn get_pump_paused(&self) -> bool

Source

pub fn get_mut_pump_paused(&mut self) -> &mut bool

Source

pub fn set_pump_paused(&mut self, val: bool) -> &mut Self

Trait Implementations§

Source§

impl Clone for MiniAppPlatform

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MiniAppPlatform

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MiniAppPlatform

Default MiniAppPlatform targeting WeChat (MiniAppVendor::WeChat).

Source§

fn default() -> Self

Creates a default WeChat Mini-Program host adapter.

§Returns
  • Self - Default MiniAppPlatform.
Source§

impl PlatformBackend for MiniAppPlatform

PlatformBackend implementation for MiniAppPlatform.

Source§

fn kind(&self) -> PlatformKind

Returns PlatformKind::MiniApp.

§Arguments
  • &Self - Mini-program platform reference.
§Returns
  • PlatformKind - PlatformKind::MiniApp.
Source§

fn capabilities(&self) -> PlatformCapabilities

Returns Mini-Program container capability flags (capsule_chrome = true, local_storage = true).

§Arguments
  • &Self - Mini-program platform reference.
§Returns
  • PlatformCapabilities - Mini-Program capabilities.
Source§

fn create_window( &mut self, config: &WindowConfig, ) -> Result<WindowState, PlatformError>

Creates a canvas window sized to the host Mini-Program viewport with capsule-cleared safe-area insets.

§Arguments
  • &Self - Mutable Mini-program platform.
  • &WindowConfig - Declarative window config.
§Returns
  • Result<WindowState, PlatformError> - Created canvas window state.
Source§

fn window_state(&self, id: WindowId) -> Option<WindowState>

Queries live WindowState for id.

§Arguments
  • &Self - Mini-program platform reference.
  • WindowId - Window identifier.
§Returns
  • Option<WindowState> - Live window state if open.
Source§

fn raw_window_handle(&self, id: WindowId) -> RawWindowHandle

Returns RawWindowHandle::MiniAppCanvas tagged with the active MiniAppVendor.

§Arguments
  • &Self - Mini-program platform reference.
  • WindowId - Window identifier.
§Returns
  • RawWindowHandle - Mini-Program canvas handle.
Source§

fn poll_events(&mut self) -> Vec<WindowEvent>

Drains queued Mini-Program touch, IME, resize, and lifecycle events.

§Arguments
  • &Self - Mutable Mini-program platform.
§Returns
  • Vec<WindowEvent> - Pending events.
Source§

fn set_frame_pump_paused(&mut self, paused: bool)

Pauses or resumes the Mini-Program canvas frame pump flag.

§Arguments
  • &Self - Mutable Mini-program platform.
  • bool - true when hidden.
Source§

fn is_frame_pump_paused(&self) -> bool

Returns whether the Mini-Program frame pump is paused.

§Arguments
  • &Self - Mini-program platform reference.
§Returns
  • bool - Pause state.
Source§

fn present_framebuffer( &mut self, id: WindowId, framebuffer: &Framebuffer, ) -> Result<(), PlatformError>

Stores framebuffer and queues a MiniAppHostCommand::PresentCanvas command for the host canvas context.

§Arguments
  • &Self - Mutable Mini-program platform.
  • WindowId - Window identifier.
  • &Framebuffer - Rendered RGBA8 framebuffer.
§Returns
  • Result<(), PlatformError> - Presentation status.
Source§

fn read_clipboard(&self) -> Option<String>

Reads cached clipboard text.

§Arguments
  • &Self - Mini-program platform reference.
§Returns
  • Option<String> - Cached clipboard string.
Source§

fn write_clipboard(&mut self, text: &str) -> Result<(), PlatformError>

Writes text to the clipboard cache and queues MiniAppHostCommand::SetClipboardData.

§Arguments
  • &Self - Mutable Mini-program platform.
  • &str - Clipboard text.
§Returns
  • Result<(), PlatformError> - Write status.
Source§

fn system_theme(&self) -> ThemeMode

Returns the active Mini-Program host theme mode.

§Arguments
  • &Self - Mini-program platform reference.
§Returns
  • ThemeMode - Active theme mode.
Source§

fn wait_for_events(&mut self) -> Vec<WindowEvent>

Blocks with zero CPU usage until at least one OS or lifecycle event arrives, then drains all pending events. Read more
Source§

fn present_framebuffer_region( &mut self, id: WindowId, framebuffer: &Framebuffer, _damage: DamageRegion, ) -> Result<(), PlatformError>

Presents a damaged sub-region of a CPU-rendered RGBA8 Framebuffer when supported by the backend. Read more
Source§

fn display_refresh_rate_hz(&self) -> f32

Queries the active display’s native hardware refresh rate in Hertz (60.0 fallback). Read more
Source§

impl PlatformHostAdapter for MiniAppPlatform

PlatformHostAdapter implementation for MiniAppPlatform.

Source§

fn device_form_factor(&self) -> DeviceFormFactor

Returns DeviceFormFactor::MiniProgram.

§Arguments
  • &Self - Mini-program platform reference.
§Returns
  • DeviceFormFactor - DeviceFormFactor::MiniProgram.
Source§

fn host_vendor_name(&self) -> &'static str

Returns the active Mini-Program vendor identifier ("wechat", "alipay", "douyin", etc.).

§Arguments
  • &Self - Mini-program platform reference.
§Returns
  • &'static str - Canonical vendor identifier.
Source§

impl PlatformLifecycleBridge for MiniAppPlatform

PlatformLifecycleBridge implementation for MiniAppPlatform.

Source§

fn freeze_surface(&mut self) -> Vec<WindowEvent>

Maps Mini-Program onHide into unified freeze semantics.

§Arguments
  • &Self - Mutable Mini-program platform.
§Returns
  • Vec<WindowEvent> - Normalized freeze events.
Source§

fn resume_surface(&mut self) -> Vec<WindowEvent>

Maps Mini-Program onShow into unified resume semantics.

§Arguments
  • &Self - Mutable Mini-program platform.
§Returns
  • Vec<WindowEvent> - Normalized resume events.
Source§

fn destroy_surface(&mut self) -> Vec<WindowEvent>

Maps Mini-Program onUnload into unified destroy semantics.

§Arguments
  • &Self - Mutable Mini-program platform.
§Returns
  • Vec<WindowEvent> - Normalized destroy events.
Source§

impl PlatformNavigation for MiniAppPlatform

PlatformNavigation implementation for MiniAppPlatform.

Source§

fn navigate_to(&mut self, route: &str) -> Result<(), PlatformError>

Pushes route onto the Mini-Program navigation stack and emits MiniAppHostCommand::NavigateTo.

§Arguments
  • &Self - Mutable Mini-program platform.
  • &str - Target page route.
§Returns
  • Result<(), PlatformError> - Navigation status.
Source§

fn navigate_back(&mut self, delta: u32) -> Result<(), PlatformError>

Pops delta entries from the navigation stack and emits MiniAppHostCommand::NavigateBack.

§Arguments
  • &Self - Mutable Mini-program platform.
  • u32 - Pages to pop.
§Returns
  • Result<(), PlatformError> - Navigation status.
Source§

fn current_route(&self) -> &str

Returns the currently active Mini-Program route path.

§Arguments
  • &Self - Mini-program platform reference.
§Returns
  • &str - Active route path.
Source§

impl PlatformStorage for MiniAppPlatform

PlatformStorage implementation for MiniAppPlatform.

Source§

fn storage_get(&self, key: &str) -> Option<String>

Reads key from mirrored Mini-Program sandbox storage.

§Arguments
  • &Self - Mini-program platform reference.
  • &str - Storage key.
§Returns
  • Option<String> - Stored value, if present.
Source§

fn storage_set(&mut self, key: &str, value: &str) -> Result<(), PlatformError>

Writes (key, value) to mirrored storage and emits MiniAppHostCommand::SetStorageSync.

§Arguments
  • &Self - Mutable Mini-program platform.
  • &str - Storage key.
  • &str - Value to store.
§Returns
  • Result<(), PlatformError> - Storage status.
Source§

fn storage_remove(&mut self, key: &str) -> Result<(), PlatformError>

Removes key from mirrored storage and emits MiniAppHostCommand::RemoveStorageSync.

§Arguments
  • &Self - Mutable Mini-program platform.
  • &str - Storage key.
§Returns
  • Result<(), PlatformError> - Removal status.
Source§

fn storage_clear(&mut self) -> Result<(), PlatformError>

Clears mirrored storage and emits MiniAppHostCommand::ClearStorageSync.

§Arguments
  • &Self - Mutable Mini-program platform.
§Returns
  • Result<(), PlatformError> - Clear status.
Source§

impl WindowController for MiniAppPlatform

WindowController implementation for MiniAppPlatform.

Source§

fn apply_command(&mut self, command: WindowCommand) -> Result<(), PlatformError>

Applies a WindowCommand and emits corresponding MiniAppHostCommands when relevant.

§Arguments
  • &Self - Mutable Mini-program platform.
  • WindowCommand - Command to apply.
§Returns
  • Result<(), PlatformError> - Execution status.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.