diff options
Diffstat (limited to 'src/module.rs')
| -rw-r--r-- | src/module.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/module.rs b/src/module.rs index c859bd3..d10e436 100644 --- a/src/module.rs +++ b/src/module.rs @@ -10,10 +10,23 @@ pub use time::TimeModule; pub mod time; -pub trait Module { +/* 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; - fn new() -> Result<Arc<Mutex<Self>>>; + fn new() -> Result<Self>; + + /* The only way to coerce to dyn is to return as it! */ + fn as_box<'a>(self) -> Box<dyn Module + 'a> + where Self: 'a + { + Box::new(self) + } +} + +pub trait Module { fn format(&mut self) -> String; fn sleep_duration(&self) -> Option<Duration>; } |