More documentation
This commit is contained in:
parent
8d8d347c56
commit
ad4fb5d2e2
1 changed files with 7 additions and 5 deletions
12
src/util.rs
12
src/util.rs
|
|
@ -21,20 +21,22 @@ impl<T: PartialEq> BaseTimer<T> {
|
|||
self.last = value;
|
||||
}
|
||||
|
||||
/// Reset the "last" value without triggering change detection
|
||||
pub fn reset_value(&mut self, value: T) {
|
||||
self.last = value;
|
||||
}
|
||||
|
||||
/// Returns true if `preset` time has passed since the last value change
|
||||
pub fn timer(&self, now: time::Instant, preset: time::Duration) -> bool {
|
||||
self.change.map(|tt| now >= tt + preset).unwrap_or(true)
|
||||
}
|
||||
|
||||
/// Returns the time since the last value change
|
||||
pub fn timer_value(&self, now: time::Instant) -> time::Duration {
|
||||
self.change
|
||||
.map(|tt| now - tt)
|
||||
.unwrap_or(time::Duration::ZERO)
|
||||
}
|
||||
|
||||
/// Reset the "last" value without triggering change detection
|
||||
pub fn reset_value(&mut self, value: T) {
|
||||
self.last = value;
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TimerResult {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue