pub struct MaxElapsedTime<P, C: Clock> { /* private fields */ }Expand description
Stops retrying once a wall-clock budget has elapsed.
On the first call to next_delay, the wrapper snapshots the current
instant from the injected Clock. Once max_elapsed has passed since
that snapshot, it returns None. Construct via
PolicyExt::max_elapsed_time.
Because the time source is injected, this works identically against a real system clock and a fully virtual test clock.
§The budget gates starting a retry, not finishing it
The elapsed-time check happens when a delay is requested, and the returned
delay is not clamped against the remaining budget. So a retry that is
permitted just before the budget expires will still sleep for its full
delay, pushing the real elapsed time past max_elapsed by up to one
interval. In other words, max_elapsed bounds when the last retry begins,
not when all waiting is guaranteed to be done. Pair it with
WithMaxDelay if you need to cap that overshoot.
Implementations§
Source§impl<P, C: Clock> MaxElapsedTime<P, C>
impl<P, C: Clock> MaxElapsedTime<P, C>
Trait Implementations§
Source§impl<P: BackoffPolicy, C: Clock> BackoffPolicy for MaxElapsedTime<P, C>
impl<P: BackoffPolicy, C: Clock> BackoffPolicy for MaxElapsedTime<P, C>
Source§impl<P: Clone, C: Clone + Clock> Clone for MaxElapsedTime<P, C>
impl<P: Clone, C: Clone + Clock> Clone for MaxElapsedTime<P, C>
Source§fn clone(&self) -> MaxElapsedTime<P, C>
fn clone(&self) -> MaxElapsedTime<P, C>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<P: Copy, C: Copy + Clock> Copy for MaxElapsedTime<P, C>
Auto Trait Implementations§
impl<P, C> Freeze for MaxElapsedTime<P, C>
impl<P, C> RefUnwindSafe for MaxElapsedTime<P, C>
impl<P, C> Send for MaxElapsedTime<P, C>
impl<P, C> Sync for MaxElapsedTime<P, C>
impl<P, C> Unpin for MaxElapsedTime<P, C>
impl<P, C> UnsafeUnpin for MaxElapsedTime<P, C>
impl<P, C> UnwindSafe for MaxElapsedTime<P, C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<P> PolicyExt for Pwhere
P: BackoffPolicy,
impl<P> PolicyExt for Pwhere
P: BackoffPolicy,
Source§fn max_attempts(self, max: u32) -> MaxAttempts<Self>
fn max_attempts(self, max: u32) -> MaxAttempts<Self>
Source§fn with_max_delay(self, max_delay: Duration) -> WithMaxDelay<Self>
fn with_max_delay(self, max_delay: Duration) -> WithMaxDelay<Self>
max_delay. See WithMaxDelay.