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