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>
where CC: Borrow<StackState<BC>>, BC: BindingsTypes,

source

pub fn core_api(&mut self) -> CoreApi<'_, &mut BC>

Retrieves a crate::api::CoreApi from this Ctx.

source

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.

source

pub fn core_ctx(&self) -> UnlockedCoreCtx<'_, BC>

Like ContextPair::contexts, but retrieves only the core context.

source

pub fn test_api(&mut self) -> TestApi<'_, BC>

Retrieves a TestApi from this Ctx.

source§

impl<BC: BindingsTypes> ContextPair<StackState<BC>, BC>

Helper functions for dealing with fake timers.

source

pub fn trigger_next_timer<Id>(&mut self) -> Option<Id>
where BC: FakeTimerCtxExt<Id>, for<'a> UnlockedCoreCtx<'a, BC>: TimerHandler<BC, Id>,

source

pub fn trigger_timers_for<Id>(&mut self, duration: Duration) -> Vec<Id>
where BC: FakeTimerCtxExt<Id>, for<'a> UnlockedCoreCtx<'a, BC>: TimerHandler<BC, Id>,

source

pub fn trigger_timers_until_instant<Id>( &mut self, instant: FakeInstant ) -> Vec<Id>
where BC: FakeTimerCtxExt<Id>, for<'a> UnlockedCoreCtx<'a, BC>: TimerHandler<BC, Id>,

Shortcut for [FaketimerCtx::trigger_timers_until_instant].

source

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>

source§

fn clone(&self) -> ContextPair<CC, BT>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<CC, BC> ContextPair for ContextPair<CC, BC>
where CC: ContextProvider, BC: ContextProvider,

§

type CoreContext = <CC as ContextProvider>::Context

The core context type held by this pair.
§

type BindingsContext = <BC as ContextProvider>::Context

The bindings context type held by this pair.
source§

fn contexts(&mut self) -> (&mut Self::CoreContext, &mut Self::BindingsContext)

Gets a mutable reference to both contexts.
source§

fn core_ctx(&mut self) -> &mut Self::CoreContext

Gets a mutable reference to the core context.
source§

fn bindings_ctx(&mut self) -> &mut Self::BindingsContext

Gets a mutable reference to the bindings context.
source§

impl<CC: Default, BT: Default> Default for ContextPair<CC, BT>

source§

fn default() -> ContextPair<CC, BT>

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

Auto Trait Implementations§

§

impl<CC, BT> Freeze for ContextPair<CC, BT>
where CC: Freeze, BT: Freeze,

§

impl<CC, BT> RefUnwindSafe for ContextPair<CC, BT>

§

impl<CC, BT> Send for ContextPair<CC, BT>
where CC: Send, BT: Send,

§

impl<CC, BT> Sync for ContextPair<CC, BT>
where CC: Sync, BT: Sync,

§

impl<CC, BT> Unpin for ContextPair<CC, BT>
where CC: Unpin, BT: Unpin,

§

impl<CC, BT> UnwindSafe for ContextPair<CC, BT>
where CC: UnwindSafe, BT: 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<Id, Ctx> FakeTimerCtxExt<Id> for Ctx
where Id: Clone, Ctx: WithFakeTimerContext<Id>,

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> Takeable for T
where T: Default,

source§

fn take(&mut self) -> T

Replaces self with an implementor-defined “empty” value.
source§

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

source§

fn handle_timer(&mut self, bindings_ctx: &mut BC, id: Id)

Handle a timer firing.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

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