pub trait PlatformBackend: WindowController {
Show 15 methods
// Required methods
fn kind(&self) -> PlatformKind;
fn capabilities(&self) -> PlatformCapabilities;
fn create_window(
&mut self,
config: &WindowConfig,
) -> Result<WindowState, PlatformError>;
fn window_state(&self, id: WindowId) -> Option<WindowState>;
fn raw_window_handle(&self, id: WindowId) -> RawWindowHandle;
fn poll_events(&mut self) -> Vec<WindowEvent>;
fn present_framebuffer(
&mut self,
id: WindowId,
framebuffer: &Framebuffer,
) -> Result<(), PlatformError>;
fn read_clipboard(&self) -> Option<String>;
fn write_clipboard(&mut self, text: &str) -> Result<(), PlatformError>;
fn system_theme(&self) -> ThemeMode;
// Provided methods
fn wait_for_events(&mut self) -> Vec<WindowEvent> { ... }
fn set_frame_pump_paused(&mut self, _paused: bool) { ... }
fn is_frame_pump_paused(&self) -> bool { ... }
fn present_framebuffer_region(
&mut self,
id: WindowId,
framebuffer: &Framebuffer,
_damage: DamageRegion,
) -> Result<(), PlatformError> { ... }
fn display_refresh_rate_hz(&self) -> f32 { ... }
}Expand description
Unified system abstraction implemented directly over each OS native API (Web, Android, iOS, iPadOS, macOS, Windows, Linux, Headless).
Required Methods§
Sourcefn kind(&self) -> PlatformKind
fn kind(&self) -> PlatformKind
Sourcefn capabilities(&self) -> PlatformCapabilities
fn capabilities(&self) -> PlatformCapabilities
Sourcefn create_window(
&mut self,
config: &WindowConfig,
) -> Result<WindowState, PlatformError>
fn create_window( &mut self, config: &WindowConfig, ) -> Result<WindowState, PlatformError>
Sourcefn window_state(&self, id: WindowId) -> Option<WindowState>
fn window_state(&self, id: WindowId) -> Option<WindowState>
Sourcefn raw_window_handle(&self, id: WindowId) -> RawWindowHandle
fn raw_window_handle(&self, id: WindowId) -> RawWindowHandle
Sourcefn poll_events(&mut self) -> Vec<WindowEvent>
fn poll_events(&mut self) -> Vec<WindowEvent>
Sourcefn present_framebuffer(
&mut self,
id: WindowId,
framebuffer: &Framebuffer,
) -> Result<(), PlatformError>
fn present_framebuffer( &mut self, id: WindowId, framebuffer: &Framebuffer, ) -> Result<(), PlatformError>
Sourcefn read_clipboard(&self) -> Option<String>
fn read_clipboard(&self) -> Option<String>
Sourcefn write_clipboard(&mut self, text: &str) -> Result<(), PlatformError>
fn write_clipboard(&mut self, text: &str) -> Result<(), PlatformError>
Sourcefn system_theme(&self) -> ThemeMode
fn system_theme(&self) -> ThemeMode
Provided Methods§
Sourcefn wait_for_events(&mut self) -> Vec<WindowEvent>
fn wait_for_events(&mut self) -> Vec<WindowEvent>
Sourcefn set_frame_pump_paused(&mut self, _paused: bool)
fn set_frame_pump_paused(&mut self, _paused: bool)
Pauses or resumes the native host frame pump when entering or leaving background-frozen state.
§Arguments
&Self- Mutable platform backend.bool-trueto pause frame pumping for background freeze;falseto resume.
Sourcefn is_frame_pump_paused(&self) -> bool
fn is_frame_pump_paused(&self) -> bool
Sourcefn present_framebuffer_region(
&mut self,
id: WindowId,
framebuffer: &Framebuffer,
_damage: DamageRegion,
) -> Result<(), PlatformError>
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.
§Arguments
&Self- Mutable platform backend.WindowId- Target window handle.&Framebuffer- Rendered RGBA8 framebuffer.DamageRegion- Damaged pixel region updated this frame.
§Returns
Result<(), PlatformError>- Presentation status.
Sourcefn display_refresh_rate_hz(&self) -> f32
fn display_refresh_rate_hz(&self) -> f32
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl PlatformBackend for HarmonyPlatform
PlatformBackend implementation for HarmonyPlatform.
impl PlatformBackend for HeadlessPlatform
PlatformBackend implementation for HeadlessPlatform.
impl PlatformBackend for LinuxPlatform
PlatformBackend implementation for native Linux.
impl PlatformBackend for MiniAppPlatform
PlatformBackend implementation for MiniAppPlatform.
impl PlatformBackend for QuickAppPlatform
PlatformBackend implementation for QuickAppPlatform.
impl PlatformBackend for TerminalPlatform
PlatformBackend implementation for TerminalPlatform.
impl PlatformBackend for WearablePlatform
PlatformBackend implementation for WearablePlatform.