TimerangeBound: add functions to extend the tolerances
(This seems much cleaner than baking extra tolerances into the "true" validity intervals")
This commit is contained in:
parent
8ef0098716
commit
d840bbbf64
|
@ -54,6 +54,19 @@ impl<T> TimerangeBound<T> {
|
|||
let end = unwrap_bound(range.end_bound());
|
||||
Self { obj, start, end }
|
||||
}
|
||||
|
||||
/// Adjust this time-range bound to tolerate an expiration time farther
|
||||
/// in the future.
|
||||
pub fn extend_tolerance(self, d: time::Duration) -> Self {
|
||||
let end = self.end.map(|t| t + d);
|
||||
Self { end, ..self }
|
||||
}
|
||||
/// Adjust this time-range bound to tolerate an initial validity
|
||||
/// time farther in the past.
|
||||
pub fn extend_pre_tolerance(self, d: time::Duration) -> Self {
|
||||
let start = self.start.map(|t| t - d);
|
||||
Self { start, ..self }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> crate::Timebound<T> for TimerangeBound<T> {
|
||||
|
|
Loading…
Reference in New Issue