Struct netstack3_core::testutil::ContextPair
source · pub struct ContextPair<CC, BT> {
pub core_ctx: CC,
pub bindings_ctx: BT,
}
Expand description
A structure holding a core and a bindings context.
Fields§
§core_ctx: CC
The core context.
bindings_ctx: BT
The bindings context.
Implementations§
source§impl<CC, BC> ContextPair<CC, BC>
impl<CC, BC> ContextPair<CC, BC>
sourcepub fn core_api(&mut self) -> CoreApi<'_, &mut BC>
pub fn core_api(&mut self) -> CoreApi<'_, &mut BC>
Retrieves a crate::api::CoreApi
from this Ctx
.
sourcepub fn contexts(&mut self) -> (UnlockedCoreCtx<'_, BC>, &mut BC)
pub fn contexts(&mut self) -> (UnlockedCoreCtx<'_, BC>, &mut BC)
Retrieves the core and bindings context, respectively.
This function can be used to call into non-api core functions that want a core context.
sourcepub fn core_ctx(&self) -> UnlockedCoreCtx<'_, BC>
pub fn core_ctx(&self) -> UnlockedCoreCtx<'_, BC>
Like ContextPair::contexts
, but retrieves only the core context.
source§impl<BC: BindingsTypes> ContextPair<StackState<BC>, BC>
impl<BC: BindingsTypes> ContextPair<StackState<BC>, BC>
Helper functions for dealing with fake timers.
sourcepub fn trigger_next_timer<Id>(&mut self) -> Option<Id>
pub fn trigger_next_timer<Id>(&mut self) -> Option<Id>
Shortcut for FakeTimerCtxExt::trigger_next_timer
.
sourcepub fn trigger_timers_for<Id>(&mut self, duration: Duration) -> Vec<Id>
pub fn trigger_timers_for<Id>(&mut self, duration: Duration) -> Vec<Id>
Shortcut for FakeTimerCtxExt::trigger_timers_for
.
sourcepub fn trigger_timers_until_instant<Id>(
&mut self,
instant: FakeInstant
) -> Vec<Id>
pub fn trigger_timers_until_instant<Id>( &mut self, instant: FakeInstant ) -> Vec<Id>
Shortcut for [FaketimerCtx::trigger_timers_until_instant
].
sourcepub fn trigger_timers_until_and_expect_unordered<Id, I: IntoIterator<Item = Id>>(
&mut self,
instant: FakeInstant,
timers: I
)where
Id: Debug + Hash + Eq,
BC: FakeTimerCtxExt<Id>,
for<'a> UnlockedCoreCtx<'a, BC>: TimerHandler<BC, Id>,
pub fn trigger_timers_until_and_expect_unordered<Id, I: IntoIterator<Item = Id>>(
&mut self,
instant: FakeInstant,
timers: I
)where
Id: Debug + Hash + Eq,
BC: FakeTimerCtxExt<Id>,
for<'a> UnlockedCoreCtx<'a, BC>: TimerHandler<BC, Id>,
Trait Implementations§
source§impl<CC: Clone, BT: Clone> Clone for ContextPair<CC, BT>
impl<CC: Clone, BT: Clone> Clone for ContextPair<CC, BT>
source§fn clone(&self) -> ContextPair<CC, BT>
fn clone(&self) -> ContextPair<CC, BT>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<CC, BC> ContextPair for ContextPair<CC, BC>where
CC: ContextProvider,
BC: ContextProvider,
impl<CC, BC> ContextPair for ContextPair<CC, BC>where
CC: ContextProvider,
BC: ContextProvider,
§type CoreContext = <CC as ContextProvider>::Context
type CoreContext = <CC as ContextProvider>::Context
§type BindingsContext = <BC as ContextProvider>::Context
type BindingsContext = <BC as ContextProvider>::Context
source§fn contexts(&mut self) -> (&mut Self::CoreContext, &mut Self::BindingsContext)
fn contexts(&mut self) -> (&mut Self::CoreContext, &mut Self::BindingsContext)
source§fn core_ctx(&mut self) -> &mut Self::CoreContext
fn core_ctx(&mut self) -> &mut Self::CoreContext
source§fn bindings_ctx(&mut self) -> &mut Self::BindingsContext
fn bindings_ctx(&mut self) -> &mut Self::BindingsContext
Auto Trait Implementations§
impl<CC, BT> Freeze for ContextPair<CC, BT>
impl<CC, BT> RefUnwindSafe for ContextPair<CC, BT>where
CC: RefUnwindSafe,
BT: RefUnwindSafe,
impl<CC, BT> Send for ContextPair<CC, BT>
impl<CC, BT> Sync for ContextPair<CC, BT>
impl<CC, BT> Unpin for ContextPair<CC, BT>
impl<CC, BT> UnwindSafe for ContextPair<CC, BT>where
CC: UnwindSafe,
BT: UnwindSafe,
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).