Struct FakeTimerCtx

Source
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: Clone> FakeTimerCtx<Id>

Source

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

Get an ordered list of all currently-scheduled timers.

Source§

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

Source

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

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: RangeBounds<FakeInstant> + Debug, I: IntoIterator<Item = (Id, R)>>( &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: IntoIterator<Item = (Id, FakeInstant)>>( &self, timers: I, )

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: RangeBounds<FakeInstant> + Debug, I: IntoIterator<Item = (Id, R)>>( &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> Default for FakeTimerCtx<Id>

Source§

fn default() -> FakeTimerCtx<Id>

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

impl<Id> InstantBindingsTypes for FakeTimerCtx<Id>

Source§

type Instant = FakeInstant

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

type AtomicInstant = FakeAtomicInstant

An atomic representation of Self::Instant.
Source§

impl<Id> InstantContext for FakeTimerCtx<Id>

Source§

fn now(&self) -> FakeInstant

Returns the current instant. Read more
Source§

fn now_atomic(&self) -> Self::AtomicInstant

Returns the current instant, as an [Self::AtomicInstant].
Source§

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

Source§

type Timer = FakeTimer<Id>

State for a timer created through TimerContext.
Source§

type DispatchId = Id

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

type UniqueTimerId = FakeTimerId

A value that uniquely identifiers a Timer. It is given along with the DispatchId whenever a timer is fired. Read more
Source§

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

Source§

fn new_timer(&mut self, dispatch_id: Self::DispatchId) -> Self::Timer

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

fn schedule_timer_instant( &mut self, time: Self::Instant, timer: &mut Self::Timer, ) -> Option<Self::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 Self::Timer) -> Option<Self::Instant>

Cancel a timer. Read more
Source§

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

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

fn unique_timer_id(&self, timer: &Self::Timer) -> Self::UniqueTimerId

Retrieves the timer id for timer. Read more
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: FnOnce(&FakeTimerCtx<TimerId>) -> O>( &self, f: F, ) -> O

Calls the callback with a borrow of FakeTimerCtx.
Source§

fn with_fake_timer_ctx_mut<O, F: FnOnce(&mut FakeTimerCtx<TimerId>) -> O>( &mut self, f: F, ) -> 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<O, BC> BuildableCoreContext<BC> for O
where O: Default,

Source§

type Builder = ()

The builder type that can build this core context.
Source§

fn build(_bindings_ctx: &mut BC, _: ()) -> O

Consumes this builder and returns the context.
§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<Id, Ctx> FakeTimerCtxExt<Id> for Ctx
where Id: Clone, Ctx: WithFakeTimerContext<Id> + TimerBindingsTypes<UniqueTimerId = FakeTimerId>,

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, 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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<CC, BC, Meta> RecvFrameContext<Meta, BC> 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<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<(), ErrorAndSerializer<SendFrameErrorReason, S>>

Send a frame. Read more
Source§

impl<BC, S, Meta, DeviceId> SendableFrameMeta<FakeCoreCtx<S, Meta, DeviceId>, BC> for Meta

Source§

fn send_meta<SS>( self, core_ctx: &mut FakeCoreCtx<S, Meta, DeviceId>, bindings_ctx: &mut BC, frame: SS, ) -> Result<(), ErrorAndSerializer<SendFrameErrorReason, SS>>
where SS: Serializer, <SS as Serializer>::Buffer: BufferMut,

Sends this frame metadata to the provided contexts.
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<(), ErrorAndSerializer<SendFrameErrorReason, S>>

Sends this frame metadata to the provided contexts.
Source§

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

Source§

fn handle_timer( &mut self, bindings_ctx: &mut BC, dispatch: Id, timer: <BC as TimerBindingsTypes>::UniqueTimerId, )

Handle a timer firing. Read more
Source§

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

Source§

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

Source§

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<L, T> UnlockedAccess<L> for T
where L: UnlockedAccessMarkerFor<T>,

§

type Data = <L as UnlockedAccessMarkerFor<T>>::Data

The type of state being accessed.
§

type Guard<'l> = &'l <L as UnlockedAccessMarkerFor<T>>::Data where T: 'l

A guard providing read access to the data.
§

fn access(&self) -> <T as UnlockedAccess<L>>::Guard<'_>

How to access the state.
§

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

§

fn vzip(self) -> V

§

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