use crate::*; use std::time::Duration; use std::thread::JoinHandle; /// Event source pub trait Input: Send + Sync + Sized { /// Type of input event type Event; /// Result of handling input type Handled; // TODO: make this an Option> containing the undo /// Currently handled event fn event (&self) -> &Self::Event; /// Whether component should exit fn is_done (&self) -> bool; /// Mark component as done fn done (&self); } /// Input thread entrypoint. pub trait InputRun { fn run_input (engine: T, state: Self, timer: Duration) -> JoinHandle<()>; } /// Handle input through a mutable reference. pub trait Handle: Send + Sync { fn handle (&mut self, _input: &E) -> Perhaps { Ok(None) } } /// Handle input through an immutable reference (e.g. [Arc] or [Arc]) pub trait HandleRef: Send + Sync { fn handle (&self, _input: &E) -> Perhaps { Ok(None) } }