pub trait AppHandler: Sized + 'static {
// Required method
fn init(engine: &mut Engine, window: &dyn Window) -> Self;
// Provided methods
fn on_event(
&mut self,
engine: &mut Engine,
window: &dyn Window,
event: &(dyn Any + 'static),
) -> bool { ... }
fn update(
&mut self,
engine: &mut Engine,
window: &dyn Window,
frame: &FrameState,
) { ... }
fn compose_frame<'a>(&'a mut self, composer: FrameComposer<'a>) { ... }
}Expand description
Trait for defining application behavior.
Implement this trait to create your application. The framework will call these methods at appropriate times during the application lifecycle.
§Lifecycle
init- Called once when the window and renderer are readyupdate- Called each frame before renderingcompose_frame- Called to configure the render pipeline
§Input Handling
Use engine.input to query input state in update.
This is the standard game development paradigm and works across all backends.
For advanced use cases that require raw platform events (e.g., integrating
an external UI framework like egui), use on_event.
The concrete event type depends on the backend; with winit it is
winit::event::WindowEvent. Downcast via event.downcast_ref::<T>().
Required Methods§
Provided Methods§
Sourcefn on_event(
&mut self,
engine: &mut Engine,
window: &dyn Window,
event: &(dyn Any + 'static),
) -> bool
fn on_event( &mut self, engine: &mut Engine, window: &dyn Window, event: &(dyn Any + 'static), ) -> bool
Handles raw platform events (advanced use only).
Most applications should use engine.input in update instead.
When using the winit backend, event is winit::event::WindowEvent.
Access it via event.downcast_ref::<winit::event::WindowEvent>().
Return true to consume the event (preventing default input processing),
or false to allow normal engine input handling.
Sourcefn update(
&mut self,
engine: &mut Engine,
window: &dyn Window,
frame: &FrameState,
)
fn update( &mut self, engine: &mut Engine, window: &dyn Window, frame: &FrameState, )
Updates application state.
Called once per frame before rendering. Use this for game logic, animations, physics updates, etc.
Sourcefn compose_frame<'a>(&'a mut self, composer: FrameComposer<'a>)
fn compose_frame<'a>(&'a mut self, composer: FrameComposer<'a>)
Configures the render pipeline for this frame.
Override this method to add custom render passes (UI, post-processing, etc.)
via the hook-based API. The default implementation only renders the built-in
pipeline (BasicForward or HighFidelity depending on RenderPath).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.