Struct netstack3_core::testutil::context::FakeBindingsCtx
source · pub struct FakeBindingsCtx<TimerId, Event, State, FrameMeta>where
Event: Debug,{
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, State, FrameMeta> FakeBindingsCtx<TimerId, Event, State, FrameMeta>where
Event: Debug,
impl<TimerId, Event, State, FrameMeta> FakeBindingsCtx<TimerId, Event, State, FrameMeta>where
Event: Debug,
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, State, FrameMeta> AsMut<FakeTimerCtx<Id>> for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
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>
fn as_mut(&mut self) -> &mut FakeTimerCtx<Id>
source§impl<Id, Event, State, FrameMeta> AsRef<FakeInstantCtx> for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
impl<Id, Event, State, FrameMeta> AsRef<FakeInstantCtx> for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
source§fn as_ref(&self) -> &FakeInstantCtx
fn as_ref(&self) -> &FakeInstantCtx
source§impl<Id, Event, State, FrameMeta> AsRef<FakeTimerCtx<Id>> for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
impl<Id, Event, State, FrameMeta> AsRef<FakeTimerCtx<Id>> for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
source§fn as_ref(&self) -> &FakeTimerCtx<Id>
fn as_ref(&self) -> &FakeTimerCtx<Id>
source§impl<TimerId, Event, State, FrameMeta> ContextProvider for FakeBindingsCtx<TimerId, Event, State, FrameMeta>where
Event: Debug,
impl<TimerId, Event, State, FrameMeta> ContextProvider for FakeBindingsCtx<TimerId, Event, State, FrameMeta>where
Event: Debug,
§type Context = FakeBindingsCtx<TimerId, Event, State, FrameMeta>
type Context = FakeBindingsCtx<TimerId, Event, State, FrameMeta>
ContextProvider
.source§fn context(
&mut self
) -> &mut <FakeBindingsCtx<TimerId, Event, State, FrameMeta> as ContextProvider>::Context
fn context( &mut self ) -> &mut <FakeBindingsCtx<TimerId, Event, State, FrameMeta> as ContextProvider>::Context
source§impl<TimerId, Event, State, FrameMeta> Default for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event, State, FrameMeta> Default for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
source§fn default() -> FakeBindingsCtx<TimerId, Event, State, FrameMeta>
fn default() -> FakeBindingsCtx<TimerId, Event, State, FrameMeta>
source§impl<Id, Event, State, FrameMeta> DeferredResourceRemovalContext for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
impl<Id, Event, State, FrameMeta> DeferredResourceRemovalContext for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
source§fn defer_removal<T>(
&mut self,
receiver: <FakeBindingsCtx<Id, Event, State, FrameMeta> as ReferenceNotifiers>::ReferenceReceiver<T>
)where
T: Send + 'static,
fn defer_removal<T>(
&mut self,
receiver: <FakeBindingsCtx<Id, Event, State, FrameMeta> as ReferenceNotifiers>::ReferenceReceiver<T>
)where
T: Send + 'static,
T
to bindings. Read moresource§fn defer_removal_result<T>(
&mut self,
result: RemoveResourceResult<T, Self::ReferenceReceiver<T>>
)where
T: Send + 'static,
fn defer_removal_result<T>(
&mut self,
result: RemoveResourceResult<T, Self::ReferenceReceiver<T>>
)where
T: Send + 'static,
defer_removal
] that takes a ReferenceReceiver
from
the Deferred
variant of a RemoveResourceResult
. Read moresource§impl<Id, Event, State, FrameMeta> EventContext<Event> for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
impl<Id, Event, State, FrameMeta> EventContext<Event> for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
source§impl<TimerId, Event, State, FrameMeta> FilterBindingsTypes for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
impl<TimerId, Event, State, FrameMeta> FilterBindingsTypes for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
§type DeviceClass = ()
type DeviceClass = ()
source§impl<D: LinkDevice, Id, Event: Debug, State, FrameMeta> LinkResolutionContext<D> for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<D: LinkDevice, Id, Event: Debug, State, FrameMeta> LinkResolutionContext<D> for FakeBindingsCtx<Id, Event, State, FrameMeta>
§type Notifier = FakeLinkResolutionNotifier<D>
type Notifier = FakeLinkResolutionNotifier<D>
source§impl<Id, Event, State, FrameMeta> ReferenceNotifiers for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
impl<Id, Event, State, FrameMeta> ReferenceNotifiers for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
§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>(
debug_references: DynDebugReferences
) -> (<FakeBindingsCtx<Id, Event, State, FrameMeta> as ReferenceNotifiers>::ReferenceNotifier<T>, <FakeBindingsCtx<Id, Event, State, FrameMeta> as ReferenceNotifiers>::ReferenceReceiver<T>)where
T: Send + 'static,
fn new_reference_notifier<T>(
debug_references: DynDebugReferences
) -> (<FakeBindingsCtx<Id, Event, State, FrameMeta> as ReferenceNotifiers>::ReferenceNotifier<T>, <FakeBindingsCtx<Id, Event, State, FrameMeta> as ReferenceNotifiers>::ReferenceReceiver<T>)where
T: Send + 'static,
T
. Read moresource§impl<TimerId, Event, State, FrameMeta> RngContext for FakeBindingsCtx<TimerId, Event, State, FrameMeta>where
Event: Debug,
impl<TimerId, Event, State, FrameMeta> RngContext for FakeBindingsCtx<TimerId, Event, State, FrameMeta>where
Event: Debug,
§type Rng<'a> = FakeCryptoRng
where
FakeBindingsCtx<TimerId, Event, State, FrameMeta>: 'a
type Rng<'a> = FakeCryptoRng where FakeBindingsCtx<TimerId, Event, State, FrameMeta>: 'a
RngContext
. Read moresource§fn rng(
&mut self
) -> <FakeBindingsCtx<TimerId, Event, State, FrameMeta> as RngContext>::Rng<'_>
fn rng( &mut self ) -> <FakeBindingsCtx<TimerId, Event, State, FrameMeta> as RngContext>::Rng<'_>
source§impl<Id, Event, State, FrameMeta> TimerBindingsTypes for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id, Event, 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, Event, State, FrameMeta> TimerContext for FakeBindingsCtx<Id, Event, State, FrameMeta>
impl<Id, Event, State, FrameMeta> TimerContext for FakeBindingsCtx<Id, Event, State, FrameMeta>
source§fn new_timer(
&mut self,
id: <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::DispatchId
) -> <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::Timer
fn new_timer( &mut self, id: <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::DispatchId ) -> <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::Timer
id
back to core when fired. Read moresource§fn schedule_timer_instant(
&mut self,
time: <FakeBindingsCtx<Id, Event, State, FrameMeta> as InstantBindingsTypes>::Instant,
timer: &mut <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::Timer
) -> Option<<FakeBindingsCtx<Id, Event, State, FrameMeta> as InstantBindingsTypes>::Instant>
fn schedule_timer_instant( &mut self, time: <FakeBindingsCtx<Id, Event, State, FrameMeta> as InstantBindingsTypes>::Instant, timer: &mut <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::Timer ) -> Option<<FakeBindingsCtx<Id, Event, State, FrameMeta> as InstantBindingsTypes>::Instant>
source§fn cancel_timer(
&mut self,
timer: &mut <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::Timer
) -> Option<<FakeBindingsCtx<Id, Event, State, FrameMeta> as InstantBindingsTypes>::Instant>
fn cancel_timer( &mut self, timer: &mut <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::Timer ) -> Option<<FakeBindingsCtx<Id, Event, State, FrameMeta> as InstantBindingsTypes>::Instant>
source§fn scheduled_instant(
&self,
timer: &mut <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::Timer
) -> Option<<FakeBindingsCtx<Id, Event, State, FrameMeta> as InstantBindingsTypes>::Instant>
fn scheduled_instant( &self, timer: &mut <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::Timer ) -> Option<<FakeBindingsCtx<Id, Event, State, FrameMeta> as InstantBindingsTypes>::Instant>
source§impl<Id, Event, State, FrameMeta> TracingContext for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
impl<Id, Event, State, FrameMeta> TracingContext for FakeBindingsCtx<Id, Event, State, FrameMeta>where
Event: Debug,
source§impl<TimerId, Event, State, FrameMeta> WithFakeTimerContext<TimerId> for FakeBindingsCtx<TimerId, Event, State, FrameMeta>where
Event: Debug,
impl<TimerId, Event, State, FrameMeta> WithFakeTimerContext<TimerId> for FakeBindingsCtx<TimerId, Event, State, FrameMeta>where
Event: Debug,
source§fn with_fake_timer_ctx<O, F>(&self, f: F) -> Owhere
F: FnOnce(&FakeTimerCtx<TimerId>) -> O,
fn with_fake_timer_ctx<O, F>(&self, f: F) -> Owhere
F: FnOnce(&FakeTimerCtx<TimerId>) -> O,
FakeTimerCtx
.source§fn with_fake_timer_ctx_mut<O, F>(&mut self, f: F) -> Owhere
F: FnOnce(&mut FakeTimerCtx<TimerId>) -> O,
fn with_fake_timer_ctx_mut<O, F>(&mut self, f: F) -> Owhere
F: FnOnce(&mut FakeTimerCtx<TimerId>) -> 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).