Trait Middleware

Source
pub trait Middleware<Init, UpdateContext, Surface, Event, EventContext, Control> {
    // Required methods
    fn on_init(&mut self, init: &mut Init);
    fn on_update(&mut self, context: &mut UpdateContext);
    fn on_render(&mut self, surface: &mut Surface);
    fn on_event(
        &mut self,
        event: Event,
        event_context: &EventContext,
        event_control: &mut Control,
    ) -> Option<Event>;
}
Expand description

Middleware is an adapter between a backend and an application itself.

Required Methods§

Source

fn on_init(&mut self, init: &mut Init)

Handle the initialization event.

Source

fn on_update(&mut self, context: &mut UpdateContext)

Handle the update tick.

Source

fn on_render(&mut self, surface: &mut Surface)

Handle render call, draw on the provided surface.

Source

fn on_event( &mut self, event: Event, event_context: &EventContext, event_control: &mut Control, ) -> Option<Event>

Handle event originated from the backend.

Implementors§

Source§

impl<App, Init, UpdateContext, Input, Surface, Event, EventContext, Control> Middleware<Init, UpdateContext, Surface, Event, EventContext, Control> for MiddlingMiddleware<App, Input>
where App: Application<Init, UpdateContext, Input, Surface>, Input: InputHandler<Event, EventContext>,