From ddc986ea05c5c17758e1028ce0d9f20dc133ec9d Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Wed, 18 Nov 2026 14:12:11 -0700 Subject: 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 --- src/modules/time.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/modules/time.rs') 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> { +impl Module for TimeModule { + const REQUIRED_FACILITIES: FacilityType = FacilityType::empty(); + + fn new() -> Result>> { 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 { + fn sleep_duration(&self) -> Option { if let Some(most_recent_report) = self.most_recent_report { let (_, _, _, millis) = most_recent_report.to_hms_milli(); -- cgit 1.4.1