use crate::error::Result; use crate::facility::{ FacilityMap, FacilityType }; use std::time::Duration; use async_channel::Sender; use async_executor::StaticExecutor; pub use battery::BatteryModule; pub use i3_mode::I3ModeModule; pub use i3_workspace::I3WorkspaceModule; pub use time::TimeModule; pub mod battery; pub mod i3_mode; pub mod i3_workspace; pub mod time; /* As with Facility, we need a separate trait for the stuff that wouldn't be * dyn-compatible. */ pub trait CreatableModule: Module + Sized { const REQUIRED_FACILITIES: FacilityType; async fn new(facilities: &mut FacilityMap, executor: &'static StaticExecutor, redraw_sender: Sender<()>) -> Result; /* The only way to coerce to dyn is to return as it! */ fn as_box<'a>(self) -> Box where Self: 'a { Box::new(self) } } pub trait Module { /* While it would be nice to make this all async, that wouldn't be * dyn-compatible. */ fn format(&mut self, facilities: &mut FacilityMap) -> Result; fn sleep_duration(&self) -> Option; fn is_visible(&self) -> bool; }