devotee_backend/lib.rs
1#![deny(missing_docs)]
2
3//! Set of definitions for backend-y stuff of the devotee project.
4
5/// So-so middleware implementation.
6pub mod middling;
7
8/// Middleware is an adapter between a backend and an application itself.
9pub trait Middleware<Init, UpdateContext, Surface, Event, EventContext, Control> {
10 /// Handle the initialization event.
11 fn on_init(&mut self, init: &mut Init);
12
13 /// Handle the update tick.
14 fn on_update(&mut self, context: &mut UpdateContext);
15
16 /// Handle render call, draw on the provided surface.
17 fn on_render(&mut self, surface: &mut Surface);
18
19 /// Handle event originated from the backend.
20 fn on_event(
21 &mut self,
22 event: Event,
23 event_context: &EventContext,
24 event_control: &mut Control,
25 ) -> Option<Event>;
26}