devotee_backend

Trait Middleware

source
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§

source

type Event

Event type to be handled;

source

type EventContext

Specific context supporting the event handling.

source

type Surface

Surface to render to.

source

type Init

Initialization context to be passed to the application.

source

type Context

Context to be passed to the application.

source

type RenderTarget

Render target to be passed to the application.

Required Methods§

source

fn init(&'a mut self, control: &'a mut Control) -> Self::Init

Initialize during startup.

source

fn update( &'a mut self, control: &'a mut Control, delta: Duration, ) -> Self::Context

Provide context for the application update process.

source

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.

source

fn render(&'a mut self, surface: Self::Surface) -> Self::RenderTarget

Provide render context for the application to draw on.

Implementors§