1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
use crate::construction::Quota; use crate::utils::Timer; /// A time quota. pub struct TimeQuota { start: Timer, limit_in_secs: f64, } impl TimeQuota { /// Creates a new instance of `TimeQuota`. pub fn new(limit_in_secs: f64) -> Self { Self { start: Timer::start(), limit_in_secs } } } impl Quota for TimeQuota { fn is_reached(&self) -> bool { self.start.elapsed_secs_as_f64() > self.limit_in_secs } }