pub trait FakeTimerCtxExt<Id>: Sized + TimerBindingsTypes {
// Required methods
fn trigger_next_timer<H: TimerHandler<Self, Id>>(
&mut self,
handler: &mut H,
) -> Option<Id>;
fn trigger_timers_until_instant<H: TimerHandler<Self, Id>>(
&mut self,
instant: FakeInstant,
handler: &mut H,
) -> Vec<Id>;
fn trigger_timers_for<H: TimerHandler<Self, Id>>(
&mut self,
duration: Duration,
handler: &mut H,
) -> Vec<Id>;
fn trigger_timers_and_expect_unordered<I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>>(
&mut self,
timers: I,
handler: &mut H,
)
where Id: Debug + Hash + Eq;
fn trigger_timers_until_and_expect_unordered<I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>>(
&mut self,
instant: FakeInstant,
timers: I,
handler: &mut H,
)
where Id: Debug + Hash + Eq;
fn trigger_timers_for_and_expect<I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>>(
&mut self,
duration: Duration,
timers: I,
handler: &mut H,
)
where Id: Debug + Hash + Eq;
}
Expand description
Adds methods for interacting with FakeTimerCtx
and its wrappers.
Required Methods§
Sourcefn trigger_next_timer<H: TimerHandler<Self, Id>>(
&mut self,
handler: &mut H,
) -> Option<Id>
fn trigger_next_timer<H: TimerHandler<Self, Id>>( &mut self, handler: &mut H, ) -> Option<Id>
Triggers the next timer, if any, by using the provided handler
.
trigger_next_timer
triggers the next timer, if any, advances the
internal clock to the timer’s scheduled time, and returns its ID.
Sourcefn trigger_timers_until_instant<H: TimerHandler<Self, Id>>(
&mut self,
instant: FakeInstant,
handler: &mut H,
) -> Vec<Id>
fn trigger_timers_until_instant<H: TimerHandler<Self, Id>>( &mut self, instant: FakeInstant, handler: &mut H, ) -> Vec<Id>
Skips the current time forward until instant
, triggering all timers
until then, inclusive, by calling f
on them.
Returns the timers which were triggered.
§Panics
Panics if instant
is in the past.
Sourcefn trigger_timers_for<H: TimerHandler<Self, Id>>(
&mut self,
duration: Duration,
handler: &mut H,
) -> Vec<Id>
fn trigger_timers_for<H: TimerHandler<Self, Id>>( &mut self, duration: Duration, handler: &mut H, ) -> Vec<Id>
Skips the current time forward by duration
, triggering all timers
until then, inclusive, by passing them to the handler
.
Returns the timers which were triggered.
Sourcefn trigger_timers_and_expect_unordered<I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>>(
&mut self,
timers: I,
handler: &mut H,
)
fn trigger_timers_and_expect_unordered<I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>>( &mut self, timers: I, handler: &mut H, )
Triggers timers and expects them to be the given timers.
The number of timers to be triggered is taken to be the number of timers
produced by timers
. Timers may be triggered in any order.
§Panics
Panics under the following conditions:
- Fewer timers could be triggered than expected
- Timers were triggered that were not expected
- Timers that were expected were not triggered
Sourcefn trigger_timers_until_and_expect_unordered<I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>>(
&mut self,
instant: FakeInstant,
timers: I,
handler: &mut H,
)
fn trigger_timers_until_and_expect_unordered<I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>>( &mut self, instant: FakeInstant, timers: I, handler: &mut H, )
Triggers timers until instant
and expects them to be the given timers.
Like trigger_timers_and_expect_unordered
, except that timers will only
be triggered until instant
(inclusive).
Sourcefn trigger_timers_for_and_expect<I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>>(
&mut self,
duration: Duration,
timers: I,
handler: &mut H,
)
fn trigger_timers_for_and_expect<I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>>( &mut self, duration: Duration, timers: I, handler: &mut H, )
Triggers timers for duration
and expects them to be the given timers.
Like trigger_timers_and_expect_unordered
, except that timers will only
be triggered for duration
(inclusive).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.