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§
Required Methods§
Sourcefn new() -> Result<Self, PlatformError>where
Self: Sized,
fn new() -> Result<Self, PlatformError>where
Self: Sized,
Create a new platform instance
Sourcefn create_event_loop(&self) -> Result<Self::EventLoop, PlatformError>
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.
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Get the platform name
Returns a string like “desktop”, “android”, or “ios”.
Sourcefn scale_factor(&self) -> f64
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.