pub trait FakeTimerCtxExt<Id>: Sized {
    // Required methods
    fn trigger_next_timer<H>(&mut self, handler: &mut H) -> Option<Id>
       where H: TimerHandler<Self, Id>;
    fn trigger_timers_until_instant<H>(
        &mut self,
        instant: FakeInstant,
        handler: &mut H
    ) -> Vec<Id>
       where H: TimerHandler<Self, Id>;
    fn trigger_timers_for<H>(
        &mut self,
        duration: Duration,
        handler: &mut H
    ) -> Vec<Id>
       where H: TimerHandler<Self, Id>;
    fn trigger_timers_and_expect_unordered<I, H>(
        &mut self,
        timers: I,
        handler: &mut H
    )
       where I: IntoIterator<Item = Id>,
             H: TimerHandler<Self, Id>,
             Id: Debug + Hash + Eq;
    fn trigger_timers_until_and_expect_unordered<I, H>(
        &mut self,
        instant: FakeInstant,
        timers: I,
        handler: &mut H
    )
       where I: IntoIterator<Item = Id>,
             H: TimerHandler<Self, Id>,
             Id: Debug + Hash + Eq;
    fn trigger_timers_for_and_expect<I, H>(
        &mut self,
        duration: Duration,
        timers: I,
        handler: &mut H
    )
       where I: IntoIterator<Item = Id>,
             H: TimerHandler<Self, Id>,
             Id: Debug + Hash + Eq;
}
Expand description

Adds methods for interacting with FakeTimerCtx and its wrappers.

Required Methods§

source

fn trigger_next_timer<H>(&mut self, handler: &mut H) -> Option<Id>
where H: TimerHandler<Self, 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.

source

fn trigger_timers_until_instant<H>( &mut self, instant: FakeInstant, handler: &mut H ) -> Vec<Id>
where H: TimerHandler<Self, 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.

source

fn trigger_timers_for<H>( &mut self, duration: Duration, handler: &mut H ) -> Vec<Id>
where H: TimerHandler<Self, 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.

source

fn trigger_timers_and_expect_unordered<I, H>( &mut self, timers: I, handler: &mut H )
where I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>, Id: Debug + Hash + Eq,

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
source

fn trigger_timers_until_and_expect_unordered<I, H>( &mut self, instant: FakeInstant, timers: I, handler: &mut H )
where I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>, Id: Debug + Hash + Eq,

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).

source

fn trigger_timers_for_and_expect<I, H>( &mut self, duration: Duration, timers: I, handler: &mut H )
where I: IntoIterator<Item = Id>, H: TimerHandler<Self, Id>, Id: Debug + Hash + Eq,

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).

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Id, Ctx> FakeTimerCtxExt<Id> for Ctx
where Id: Clone, Ctx: WithFakeTimerContext<Id>,