diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-11-18 14:12:11 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-11-18 14:12:11 -0700 |
| commit | ddc986ea05c5c17758e1028ce0d9f20dc133ec9d (patch) | |
| tree | 417111926032329d71ce8a292c151b04fffa7201 /src/modules | |
| parent | 01f5b773ab89b809059e2212feb8547f8b073e91 (diff) | |
add an abstraction called "facilities", which does nothing yet
the type system work was a pain, so it's being checked in now Force-Push: yes Change-Id: If7ec15f0108afb030fa2e5a207c77a6cf9828c43
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/time.rs | 18 |
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(); |