rlvgl_core/interface.rs
1//! Traits for hardware abstraction (Display, Input, Time).
2//!
3//! These traits decouple the application logic from the underlying execution environment
4//! (Simulator vs Embedded Firmware).
5
6use crate::event::Event;
7use crate::renderer::Renderer;
8
9/// Driver for a physical or simulated display.
10pub trait DisplayDriver {
11 /// The concrete renderer implementation used by this display.
12 type Renderer: Renderer;
13
14 /// Acquire a renderer for the current frame and invoke the drawing closure.
15 fn draw<F>(&mut self, f: F)
16 where
17 F: FnOnce(&mut Self::Renderer);
18}
19
20/// Driver for input events.
21pub trait InputDriver {
22 /// Poll for a pending event, if any.
23 fn poll_event(&mut self) -> Option<Event>;
24}
25
26/// Source of monotonic time.
27pub trait TimeSource {
28 /// Returns the current time in milliseconds.
29 fn now_ms(&self) -> u64;
30}