pub trait App {
type Args: Sized + Parser;
// Required method
fn new(window: &mut Window, args: &Self::Args) -> Result<Self>
where Self: Sized;
// Provided methods
fn handle_window_event(
&mut self,
window: &mut Window,
event: WindowEvent,
) -> Result<AppState> { ... }
fn handle_device_event(
&mut self,
window: &mut Window,
event: DeviceEvent,
) -> Result<AppState> { ... }
fn update(&mut self, window: &mut Window) -> Result<AppState> { ... }
}Expand description
Implementations of this trait can be run with app_main to manage a Winit window.
Required Associated Types§
Required Methods§
Sourcefn new(window: &mut Window, args: &Self::Args) -> Result<Self>where
Self: Sized,
fn new(window: &mut Window, args: &Self::Args) -> Result<Self>where
Self: Sized,
Creates a new instance of the application. The application is allowed to modify the window based on its own requirements. This includes modifying the polling state, fullscreen status, size, etc…
Note: the window is not visible when initially created, the app must choose when to make it visible for the first time.
Provided Methods§
Sourcefn handle_window_event(
&mut self,
window: &mut Window,
event: WindowEvent,
) -> Result<AppState>
fn handle_window_event( &mut self, window: &mut Window, event: WindowEvent, ) -> Result<AppState>
Handles a single WindowEvent.
Sourcefn handle_device_event(
&mut self,
window: &mut Window,
event: DeviceEvent,
) -> Result<AppState>
fn handle_device_event( &mut self, window: &mut Window, event: DeviceEvent, ) -> Result<AppState>
Handles a single DeviceEvent.