Simplify/clarify watchdog code
- Use Debug trait object rather than arbitrary closure
- Combine bool+Instant into Option<Instant>
- Disambiguate "timeout"
- Add comments
- Simplify multi-argument matches
Test: keystore2_test
Test: libwatchdog_rs.test
Flag: None, refactor
Change-Id: Ieb16257c763fc2e04d592d97f341fea27aad726f
diff --git a/keystore2/src/watchdog_helper.rs b/keystore2/src/watchdog_helper.rs
index 03c7740..1072ac0 100644
--- a/keystore2/src/watchdog_helper.rs
+++ b/keystore2/src/watchdog_helper.rs
@@ -43,14 +43,14 @@
Watchdog::watch(&WD, id, DEFAULT_TIMEOUT)
}
- /// Like `watch_millis` but with a callback that is called every time a report
- /// is printed about this watch point.
+ /// Like `watch_millis` but with context that is included every time a report is printed about
+ /// this watch point.
pub fn watch_millis_with(
id: &'static str,
millis: u64,
- callback: impl Fn() -> String + Send + 'static,
+ context: impl std::fmt::Debug + Send + 'static,
) -> Option<WatchPoint> {
- Watchdog::watch_with(&WD, id, Duration::from_millis(millis), callback)
+ Watchdog::watch_with(&WD, id, Duration::from_millis(millis), context)
}
}
@@ -71,7 +71,7 @@
pub fn watch_millis_with(
_: &'static str,
_: u64,
- _: impl Fn() -> String + Send + 'static,
+ _: impl std::fmt::Debug + Send + 'static,
) -> Option<WatchPoint> {
None
}