use super::*;
pub trait PlatformBackend: WindowController {
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 wait_for_events(&mut self) -> Vec<WindowEvent> {
self.poll_events()
}
fn set_frame_pump_paused(&mut self, _paused: bool) {}
fn is_frame_pump_paused(&self) -> bool {
false
}
fn present_framebuffer(
&mut self,
id: WindowId,
framebuffer: &Framebuffer,
) -> Result<(), PlatformError>;
fn present_framebuffer_region(
&mut self,
id: WindowId,
framebuffer: &Framebuffer,
_damage: DamageRegion,
) -> Result<(), PlatformError> {
self.present_framebuffer(id, framebuffer)
}
fn read_clipboard(&self) -> Option<String>;
fn write_clipboard(&mut self, text: &str) -> Result<(), PlatformError>;
fn system_theme(&self) -> ThemeMode;
fn display_refresh_rate_hz(&self) -> f32 {
60.0
}
}
pub trait PlatformStorage {
fn storage_get(&self, key: &str) -> Option<String>;
fn storage_set(&mut self, key: &str, value: &str) -> Result<(), PlatformError>;
fn storage_remove(&mut self, key: &str) -> Result<(), PlatformError>;
fn storage_clear(&mut self) -> Result<(), PlatformError>;
}
pub trait PlatformNavigation {
fn navigate_to(&mut self, route: &str) -> Result<(), PlatformError>;
fn navigate_back(&mut self, delta: u32) -> Result<(), PlatformError>;
fn current_route(&self) -> &str;
}
pub trait PlatformLifecycleBridge {
fn freeze_surface(&mut self) -> Vec<WindowEvent>;
fn resume_surface(&mut self) -> Vec<WindowEvent>;
fn destroy_surface(&mut self) -> Vec<WindowEvent>;
}
pub trait PlatformHostAdapter:
PlatformBackend + PlatformStorage + PlatformNavigation + PlatformLifecycleBridge
{
fn device_form_factor(&self) -> DeviceFormFactor;
fn host_vendor_name(&self) -> &'static str;
}