pub trait PlatformBackend: WindowController {
// 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 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 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 HeadlessPlatform
PlatformBackend implementation for HeadlessPlatform.
impl PlatformBackend for LinuxPlatform
PlatformBackend implementation for native Linux.