pub struct FakeTimerCtx<Id> {
    pub instant: FakeInstantCtx,
    pub timers: BinaryHeap<InstantAndData<FakeTimer<Id>>>,
    /* private fields */
}
Expand description

A fake TimerContext which stores time as a FakeInstantCtx.

Fields§

§instant: FakeInstantCtx

The instant context within this fake timer context.

§timers: BinaryHeap<InstantAndData<FakeTimer<Id>>>

The timer heap kept by the fake implementation.

Implementations§

source§

impl<Id> FakeTimerCtx<Id>
where Id: Clone,

source

pub fn timers(&self) -> Vec<(FakeInstant, Id)>

Get an ordered list of all currently-scheduled timers.

source§

impl<Id> FakeTimerCtx<Id>
where Id: Debug + Clone + Hash + Eq,

source

pub fn assert_timers_installed<I>(&self, timers: I)
where I: IntoIterator<Item = (Id, FakeInstant)>,

Asserts that self contains exactly the timers in timers.

§Panics

Panics if timers contains the same ID more than once or if self does not contain exactly the timers in timers.

source

pub fn assert_timers_installed_range<R, I>(&self, timers: I)

Like [assert_timers_installed] but receives a range instants to match.

Each timer must be present, and its deadline must fall into the specified range.

source

pub fn assert_some_timers_installed<I>(&self, timers: I)
where I: IntoIterator<Item = (Id, FakeInstant)>,

Asserts that self contains at least the timers in timers.

Like [assert_timers_installed], but only asserts that timers is a subset of the timers installed; other timers may be installed in addition to those in timers.

source

pub fn assert_some_timers_installed_range<R, I>(&self, timers: I)

Like [assert_some_timers_installed] but receives instant ranges to match like [assert_timers_installed_range].

source

pub fn assert_no_timers_installed(&self)

Asserts that no timers are installed.

§Panics

Panics if any timers are installed.

Trait Implementations§

source§

impl<Id, Event, State, FrameMeta> AsMut<FakeTimerCtx<Id>> for FakeBindingsCtx<Id, Event, State, FrameMeta>
where Event: Debug,

source§

fn as_mut(&mut self) -> &mut FakeTimerCtx<Id>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<Id> AsRef<FakeInstantCtx> for FakeTimerCtx<Id>

source§

fn as_ref(&self) -> &FakeInstantCtx

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<Id, Event, State, FrameMeta> AsRef<FakeTimerCtx<Id>> for FakeBindingsCtx<Id, Event, State, FrameMeta>
where Event: Debug,

source§

fn as_ref(&self) -> &FakeTimerCtx<Id>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<Id> Default for FakeTimerCtx<Id>

source§

fn default() -> FakeTimerCtx<Id>

Returns the “default value” for a type. Read more
source§

impl<Id> TimerBindingsTypes for FakeTimerCtx<Id>
where Id: Debug + Clone + Send + Sync,

§

type Timer = FakeTimer<Id>

State for a timer created through TimerContext.
§

type DispatchId = Id

The type used to dispatch fired timers from bindings to core.
source§

impl<Id> TimerContext for FakeTimerCtx<Id>
where Id: PartialEq + Debug + Clone + Send + Sync,

source§

fn new_timer( &mut self, dispatch_id: <FakeTimerCtx<Id> as TimerBindingsTypes>::DispatchId ) -> <FakeTimerCtx<Id> as TimerBindingsTypes>::Timer

Creates a new timer that dispatches id back to core when fired. Read more
source§

fn schedule_timer_instant( &mut self, time: <FakeTimerCtx<Id> as InstantBindingsTypes>::Instant, timer: &mut <FakeTimerCtx<Id> as TimerBindingsTypes>::Timer ) -> Option<<FakeTimerCtx<Id> as InstantBindingsTypes>::Instant>

Schedule a timer to fire at some point in the future. Returns the previously scheduled instant, if this timer was scheduled.
source§

fn cancel_timer( &mut self, timer: &mut <FakeTimerCtx<Id> as TimerBindingsTypes>::Timer ) -> Option<<FakeTimerCtx<Id> as InstantBindingsTypes>::Instant>

Cancel a timer. Read more
source§

fn scheduled_instant( &self, timer: &mut <FakeTimerCtx<Id> as TimerBindingsTypes>::Timer ) -> Option<<FakeTimerCtx<Id> as InstantBindingsTypes>::Instant>

Get the instant a timer will fire, if one is scheduled.
source§

fn schedule_timer( &mut self, duration: Duration, timer: &mut Self::Timer ) -> Option<Self::Instant>

Like [schedule_timer_instant] but schedules a time for duration in the future.
source§

impl<TimerId> WithFakeTimerContext<TimerId> for FakeTimerCtx<TimerId>

source§

fn with_fake_timer_ctx<O, F>(&self, f: F) -> O
where F: FnOnce(&FakeTimerCtx<TimerId>) -> O,

Calls the callback with a borrow of FakeTimerCtx.
source§

fn with_fake_timer_ctx_mut<O, F>(&mut self, f: F) -> O
where F: FnOnce(&mut FakeTimerCtx<TimerId>) -> O,

Calls the callback with a mutable borrow of FakeTimerCtx.

Auto Trait Implementations§

§

impl<Id> Freeze for FakeTimerCtx<Id>

§

impl<Id> RefUnwindSafe for FakeTimerCtx<Id>
where Id: RefUnwindSafe,

§

impl<Id> Send for FakeTimerCtx<Id>
where Id: Send,

§

impl<Id> Sync for FakeTimerCtx<Id>
where Id: Sync,

§

impl<Id> Unpin for FakeTimerCtx<Id>
where Id: Unpin,

§

impl<Id> UnwindSafe for FakeTimerCtx<Id>
where Id: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

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

source§

fn trigger_next_timer<H>(&mut self, handler: &mut H) -> Option<Id>
where H: TimerHandler<Ctx, Id>,

Triggers the next timer, if any, by calling f on it.

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<Ctx, Id>,

Skips the current time forward until instant, triggering all timers until then, inclusive, by giving them to handler.

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<Ctx, Id>,

Skips the current time forward by duration, triggering all timers until then, inclusive, by calling f on them.

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

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> InstantBindingsTypes for T

§

type Instant = FakeInstant

The type of an instant in time. Read more
source§

impl<T> InstantContext for T

source§

fn now(&self) -> FakeInstant

Returns the current instant. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<CC, BC, Meta> RecvFrameContext<BC, Meta> for CC
where Meta: ReceivableFrameMeta<CC, BC>,

source§

fn receive_frame<B>(&mut self, bindings_ctx: &mut BC, metadata: Meta, frame: B)
where B: BufferMut + Debug,

Receive a frame. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<CC, BC, Meta> SendFrameContext<BC, Meta> for CC
where Meta: SendableFrameMeta<CC, BC>,

source§

fn send_frame<S>( &mut self, bindings_ctx: &mut BC, metadata: Meta, frame: S ) -> Result<(), S>
where S: Serializer, <S as Serializer>::Buffer: BufferMut,

Send a frame. Read more
source§

impl<Meta, BC> SendableFrameMeta<FakeFrameCtx<Meta>, BC> for Meta

source§

fn send_meta<S>( self, core_ctx: &mut FakeFrameCtx<Meta>, _bindings_ctx: &mut BC, frame: S ) -> Result<(), S>
where S: Serializer, <S as Serializer>::Buffer: BufferMut,

Sends this frame metadata to the provided contexts.
source§

impl<T> Takeable for T
where T: Default,

source§

fn take(&mut self) -> T

Replaces self with an implementor-defined “empty” value.
source§

impl<Id, CC, BC> TimerHandler<BC, Id> for CC
where Id: HandleableTimer<CC, BC>,

source§

fn handle_timer(&mut self, bindings_ctx: &mut BC, id: Id)

Handle a timer firing.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<B, A> LockBefore<B> for A
where B: LockAfter<A>,