pub struct FakeBindingsCtx<TimerId, Event: Debug, State, FrameMeta> {
pub rng: FakeCryptoRng,
pub timers: FakeTimerCtx<TimerId>,
pub events: FakeEventCtx<Event>,
pub frames: FakeFrameCtx<FrameMeta>,
pub state: State,
}
Expand description
A test helper used to provide an implementation of a bindings context.
Fields§
§rng: FakeCryptoRng
Provides RngContext
.
timers: FakeTimerCtx<TimerId>
Provides TimerContext
.
events: FakeEventCtx<Event>
Provides EventContext
.
frames: FakeFrameCtx<FrameMeta>
Provides [SendFrameContext
].
state: State
Generic state used by specific tests.
Implementations§
Source§impl<TimerId, Event: Debug, State, FrameMeta> FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event: Debug, State, FrameMeta> FakeBindingsCtx<TimerId, Event, State, FrameMeta>
Sourcepub fn take_events(&mut self) -> Vec<Event>
pub fn take_events(&mut self) -> Vec<Event>
Takes all the accumulated events from the FakeEventCtx
.
Trait Implementations§
Source§impl<TimerId, Event: Debug, State, FrameMeta> ContextProvider for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event: Debug, State, FrameMeta> ContextProvider for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
Source§impl<TimerId, Event: Debug, State: Default, FrameMeta> Default for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event: Debug, State: Default, FrameMeta> Default for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
Source§impl<Id, Event: Debug, State, FrameMeta> DeferredResourceRemovalContext for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id, Event: Debug, State, FrameMeta> DeferredResourceRemovalContext for FakeBindingsCtx<Id, Event, State, FrameMeta>
Source§fn defer_removal<T: Send + 'static>(
&mut self,
receiver: Self::ReferenceReceiver<T>,
)
fn defer_removal<T: Send + 'static>( &mut self, receiver: Self::ReferenceReceiver<T>, )
T
to bindings. Read moreSource§fn defer_removal_result<T: Send + 'static>(
&mut self,
result: RemoveResourceResultWithContext<T, Self>,
)
fn defer_removal_result<T: Send + 'static>( &mut self, result: RemoveResourceResultWithContext<T, Self>, )
defer_removal
] that takes a ReferenceReceiver
from
the Deferred
variant of a RemoveResourceResult
. Read moreSource§impl<Id, Event: Debug, State, FrameMeta> EventContext<Event> for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id, Event: Debug, State, FrameMeta> EventContext<Event> for FakeBindingsCtx<Id, Event, State, FrameMeta>
Source§impl<TimerId, Event: Debug, State, FrameMeta> InstantBindingsTypes for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event: Debug, State, FrameMeta> InstantBindingsTypes for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
Source§type Instant = FakeInstant
type Instant = FakeInstant
Source§type AtomicInstant = FakeAtomicInstant
type AtomicInstant = FakeAtomicInstant
Self::Instant
.Source§impl<TimerId, Event: Debug, State, FrameMeta> InstantContext for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event: Debug, State, FrameMeta> InstantContext for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
Source§fn now_atomic(&self) -> Self::AtomicInstant
fn now_atomic(&self) -> Self::AtomicInstant
Self::AtomicInstant
].Source§impl<Id, Event: Debug, State, FrameMeta> ReferenceNotifiers for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id, Event: Debug, State, FrameMeta> ReferenceNotifiers for FakeBindingsCtx<Id, Event, State, FrameMeta>
Source§type ReferenceReceiver<T: 'static> = Infallible
type ReferenceReceiver<T: 'static> = Infallible
Source§type ReferenceNotifier<T: Send + 'static> = Infallible
type ReferenceNotifier<T: Send + 'static> = Infallible
Source§fn new_reference_notifier<T: Send + 'static>(
debug_references: DynDebugReferences,
) -> (Self::ReferenceNotifier<T>, Self::ReferenceReceiver<T>)
fn new_reference_notifier<T: Send + 'static>( debug_references: DynDebugReferences, ) -> (Self::ReferenceNotifier<T>, Self::ReferenceReceiver<T>)
T
. Read moreSource§impl<TimerId, Event: Debug, State, FrameMeta> RngContext for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event: Debug, State, FrameMeta> RngContext for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
Source§impl<Id: Debug + PartialEq + Clone + Send + Sync, Event: Debug, State, FrameMeta> TimerBindingsTypes for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id: Debug + PartialEq + Clone + Send + Sync, Event: Debug, State, FrameMeta> TimerBindingsTypes for FakeBindingsCtx<Id, Event, State, FrameMeta>
Source§type Timer = <FakeTimerCtx<Id> as TimerBindingsTypes>::Timer
type Timer = <FakeTimerCtx<Id> as TimerBindingsTypes>::Timer
TimerContext
.Source§type DispatchId = <FakeTimerCtx<Id> as TimerBindingsTypes>::DispatchId
type DispatchId = <FakeTimerCtx<Id> as TimerBindingsTypes>::DispatchId
Source§type UniqueTimerId = <FakeTimerCtx<Id> as TimerBindingsTypes>::UniqueTimerId
type UniqueTimerId = <FakeTimerCtx<Id> as TimerBindingsTypes>::UniqueTimerId
Timer
. It is given along with the
DispatchId
whenever a timer is fired. Read moreSource§impl<Id: Debug + PartialEq + Clone + Send + Sync, Event: Debug, State, FrameMeta> TimerContext for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id: Debug + PartialEq + Clone + Send + Sync, Event: Debug, State, FrameMeta> TimerContext for FakeBindingsCtx<Id, Event, State, FrameMeta>
Source§fn new_timer(&mut self, id: Self::DispatchId) -> Self::Timer
fn new_timer(&mut self, id: Self::DispatchId) -> Self::Timer
id
back to core when fired. Read moreSource§fn schedule_timer_instant(
&mut self,
time: Self::Instant,
timer: &mut Self::Timer,
) -> Option<Self::Instant>
fn schedule_timer_instant( &mut self, time: Self::Instant, timer: &mut Self::Timer, ) -> Option<Self::Instant>
Source§fn cancel_timer(&mut self, timer: &mut Self::Timer) -> Option<Self::Instant>
fn cancel_timer(&mut self, timer: &mut Self::Timer) -> Option<Self::Instant>
Source§fn scheduled_instant(&self, timer: &mut Self::Timer) -> Option<Self::Instant>
fn scheduled_instant(&self, timer: &mut Self::Timer) -> Option<Self::Instant>
Source§fn unique_timer_id(&self, timer: &Self::Timer) -> Self::UniqueTimerId
fn unique_timer_id(&self, timer: &Self::Timer) -> Self::UniqueTimerId
timer
. Read moreSource§impl<TimerId, Event: Debug, State, FrameMeta> TxMetadataBindingsTypes for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event: Debug, State, FrameMeta> TxMetadataBindingsTypes for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
Source§type TxMetadata = FakeTxMetadata
type TxMetadata = FakeTxMetadata
Source§impl<TimerId, Event: Debug, State, FrameMeta> WithFakeTimerContext<TimerId> for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event: Debug, State, FrameMeta> WithFakeTimerContext<TimerId> for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
Source§fn with_fake_timer_ctx<O, F: FnOnce(&FakeTimerCtx<TimerId>) -> O>(
&self,
f: F,
) -> O
fn with_fake_timer_ctx<O, F: FnOnce(&FakeTimerCtx<TimerId>) -> O>( &self, f: F, ) -> O
FakeTimerCtx
.Source§fn with_fake_timer_ctx_mut<O, F: FnOnce(&mut FakeTimerCtx<TimerId>) -> O>(
&mut self,
f: F,
) -> O
fn with_fake_timer_ctx_mut<O, F: FnOnce(&mut FakeTimerCtx<TimerId>) -> O>( &mut self, f: F, ) -> O
FakeTimerCtx
.impl<TimerId, Event: Debug, State, FrameMeta> AlwaysDefaultsSettingsContext for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
Auto Trait Implementations§
impl<TimerId, Event, State, FrameMeta> Freeze for FakeBindingsCtx<TimerId, Event, State, FrameMeta>where
State: Freeze,
impl<TimerId, Event, State, FrameMeta> !RefUnwindSafe for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event, State, FrameMeta> Send for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event, State, FrameMeta> !Sync for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event, State, FrameMeta> Unpin for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event, State, FrameMeta> !UnwindSafe for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
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<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
impl<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<Id, Ctx> FakeTimerCtxExt<Id> for Ctx
impl<Id, Ctx> FakeTimerCtxExt<Id> for Ctx
Source§fn trigger_next_timer<H>(&mut self, handler: &mut H) -> Option<Id>where
H: TimerHandler<Ctx, Id>,
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>,
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>,
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,
)
fn trigger_timers_and_expect_unordered<I, H>( &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
Source§fn trigger_timers_until_and_expect_unordered<I, H>(
&mut self,
instant: FakeInstant,
timers: I,
handler: &mut H,
)
fn trigger_timers_until_and_expect_unordered<I, H>( &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).
Source§fn trigger_timers_for_and_expect<I, H>(
&mut self,
duration: Duration,
timers: I,
handler: &mut H,
)
fn trigger_timers_for_and_expect<I, H>( &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).
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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