about summary refs log tree commit diff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/time.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/modules/time.rs b/src/modules/time.rs
index 25c5864..b7c2634 100644
--- a/src/modules/time.rs
+++ b/src/modules/time.rs
@@ -1,3 +1,7 @@
+use crate::error::Result;
+use crate::facilities::FacilityType;
+use crate::modules::Module;
+
 use std::sync::{ Arc, Mutex };
 use std::time::Duration;
 
@@ -11,21 +15,23 @@ pub struct TimeModule {
 }
 
 
-impl TimeModule {
-  pub fn new() -> Arc<Mutex<TimeModule>> {
+impl Module for TimeModule {
+  const REQUIRED_FACILITIES: FacilityType = FacilityType::empty();
+
+  fn new() -> Result<Arc<Mutex<TimeModule>>> {
     let format_string = 
         "[weekday repr:short] [year]-[month]-[day] ".to_owned()
         + "[hour repr:24]:[minute]:[second]";
 
     let time_format = parse_owned::<3>(&format_string).unwrap();
 
-    Arc::new(Mutex::new(TimeModule {
+    Ok(Arc::new(Mutex::new(TimeModule {
       time_format,
       most_recent_report: None,
-    }))
+    })))
   }
 
-  pub fn format(&mut self) -> String {
+  fn format(&mut self) -> String {
     let time = OffsetDateTime::now_local().unwrap();
 
     self.most_recent_report = Some(time);
@@ -33,7 +39,7 @@ impl TimeModule {
     time.format(&self.time_format).unwrap()
   }
 
-  pub fn sleep_duration(&self) -> Option<Duration> {
+  fn sleep_duration(&self) -> Option<Duration> {
     if let Some(most_recent_report) = self.most_recent_report {
       let (_, _, _, millis) = most_recent_report.to_hms_milli();