about summary refs log tree commit diff
path: root/src/module.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-11-18 16:38:51 -0700
committerIrene Knapp <ireneista@irenes.space>2026-11-18 16:38:51 -0700
commitdcf0c6ce5ce21647640b2b35715ede50a5a97881 (patch)
tree7cf9e269511074553181883df16a4b1e6269bb37 /src/module.rs
parent0bcfe7b468a83436a077824ca60e09c5fdd3f803 (diff)
dyn Module
fun

this also seemed a good time to clean up the bibliography and publish it

Force-Push: yes
Change-Id: Ia8014fb84c1af37be4f3c915b8b8f70bc2022034
Diffstat (limited to 'src/module.rs')
-rw-r--r--src/module.rs17
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>;
 }