Struct netstack3_base::testutil::FakeBindingsCtx
source · 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<Id, Event: Debug, State, FrameMeta> AsMut<FakeTimerCtx<Id>> for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id, Event: Debug, State, FrameMeta> AsMut<FakeTimerCtx<Id>> for FakeBindingsCtx<Id, Event, State, FrameMeta>
source§fn as_mut(&mut self) -> &mut FakeTimerCtx<Id>
fn as_mut(&mut self) -> &mut FakeTimerCtx<Id>
source§impl<Id, Event: Debug, State, FrameMeta> AsRef<FakeInstantCtx> for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id, Event: Debug, State, FrameMeta> AsRef<FakeInstantCtx> for FakeBindingsCtx<Id, Event, State, FrameMeta>
source§fn as_ref(&self) -> &FakeInstantCtx
fn as_ref(&self) -> &FakeInstantCtx
source§impl<Id, Event: Debug, State, FrameMeta> AsRef<FakeTimerCtx<Id>> for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id, Event: Debug, State, FrameMeta> AsRef<FakeTimerCtx<Id>> for FakeBindingsCtx<Id, Event, State, FrameMeta>
source§fn as_ref(&self) -> &FakeTimerCtx<Id>
fn as_ref(&self) -> &FakeTimerCtx<Id>
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<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>
§type ReferenceReceiver<T: 'static> = Infallible
type ReferenceReceiver<T: 'static> = Infallible
§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>
§type Timer = <FakeTimerCtx<Id> as TimerBindingsTypes>::Timer
type Timer = <FakeTimerCtx<Id> as TimerBindingsTypes>::Timer
TimerContext
.§type DispatchId = <FakeTimerCtx<Id> as TimerBindingsTypes>::DispatchId
type DispatchId = <FakeTimerCtx<Id> as TimerBindingsTypes>::DispatchId
source§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§impl<Id, Event: Debug, State, FrameMeta> TracingContext for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id, Event: Debug, State, FrameMeta> TracingContext for FakeBindingsCtx<Id, Event, State, FrameMeta>
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
.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<Id, Ctx> FakeTimerCtxExt<Id> for Ctxwhere
Id: Clone,
Ctx: WithFakeTimerContext<Id>,
impl<Id, Ctx> FakeTimerCtxExt<Id> for Ctxwhere
Id: Clone,
Ctx: WithFakeTimerContext<Id>,
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).