Skip to main content

Platform

Trait Platform 

Source
pub trait Platform: Send + Sync {
    type Window: Window;
    type EventLoop: EventLoop<Window = Self::Window>;

    // Required methods
    fn new() -> Result<Self, PlatformError>
       where Self: Sized;
    fn create_event_loop(&self) -> Result<Self::EventLoop, PlatformError>;
    fn name(&self) -> &'static str;
    fn scale_factor(&self) -> f64;
}
Expand description

Platform abstraction trait

This trait is implemented by each platform backend (desktop, android, ios) to provide a unified interface for creating windows and running event loops.

Required Associated Types§

Source

type Window: Window

The window type for this platform

Source

type EventLoop: EventLoop<Window = Self::Window>

The event loop type for this platform

Required Methods§

Source

fn new() -> Result<Self, PlatformError>
where Self: Sized,

Create a new platform instance

Source

fn create_event_loop(&self) -> Result<Self::EventLoop, PlatformError>

Create an event loop

The event loop is used to receive platform events and drive the application’s main loop.

Source

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

Get the platform name

Returns a string like “desktop”, “android”, or “ios”.

Source

fn scale_factor(&self) -> f64

Get the default display scale factor

This returns the system’s default scale factor for DPI scaling. Individual windows may have different scale factors.

Implementors§