1use thiserror::Error;
2
3use crate::{
4 environment::Environment,
5 map::Map,
6 window::{HeadedMapWindow, MapWindowConfig},
7};
8
9pub trait EventLoopConfig {
10 type EventType: 'static;
11 type EventLoopProxy: EventLoopProxy<Self::EventType>;
12
13 fn create_proxy() -> Self::EventLoopProxy;
14}
15
16#[derive(Error, Debug)]
18pub enum SendEventError {
19 #[error("event loop is closed")]
21 Closed,
22}
23
24pub trait EventLoopProxy<T: 'static> {
25 fn send_event(&self, event: T) -> Result<(), SendEventError>;
26}
27
28pub trait EventLoop<ET: 'static + PartialEq> {
29 type EventLoopProxy: EventLoopProxy<ET>;
30
31 fn run<E>(self, map: Map<E>, max_frames: Option<u64>)
32 where
33 E: Environment,
34 <E::MapWindowConfig as MapWindowConfig>::MapWindow: HeadedMapWindow;
35
36 fn create_proxy(&self) -> Self::EventLoopProxy;
37}