pub trait Middleware<'a, Control> {
type Event;
type EventContext;
type Surface;
type Init;
type Context;
type RenderTarget;
// Required methods
fn init(&'a mut self, control: &'a mut Control) -> Self::Init;
fn update(
&'a mut self,
control: &'a mut Control,
delta: Duration,
) -> Self::Context;
fn handle_event(
&mut self,
event: Self::Event,
event_context: Self::EventContext,
control: &mut Control,
) -> Option<Self::Event>;
fn render(&'a mut self, surface: Self::Surface) -> Self::RenderTarget;
}
Expand description
Middleware trait.
Required Associated Types§
sourcetype EventContext
type EventContext
Specific context supporting the event handling.
sourcetype RenderTarget
type RenderTarget
Render target to be passed to the application.
Required Methods§
sourcefn init(&'a mut self, control: &'a mut Control) -> Self::Init
fn init(&'a mut self, control: &'a mut Control) -> Self::Init
Initialize during startup.
sourcefn update(
&'a mut self,
control: &'a mut Control,
delta: Duration,
) -> Self::Context
fn update( &'a mut self, control: &'a mut Control, delta: Duration, ) -> Self::Context
Provide context for the application update process.
sourcefn handle_event(
&mut self,
event: Self::Event,
event_context: Self::EventContext,
control: &mut Control,
) -> Option<Self::Event>
fn handle_event( &mut self, event: Self::Event, event_context: Self::EventContext, control: &mut Control, ) -> Option<Self::Event>
Handle event generated by the backend, return it if not consumed.
sourcefn render(&'a mut self, surface: Self::Surface) -> Self::RenderTarget
fn render(&'a mut self, surface: Self::Surface) -> Self::RenderTarget
Provide render context for the application to draw on.