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,

source

pub fn seed_rng(&mut self, seed: u128)

Seed the testing RNG with a specific value.

source

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,

source§

fn as_mut(&mut self) -> &mut FakeTimerCtx<Id>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<Id, Event, State, FrameMeta> AsRef<FakeInstantCtx> for FakeBindingsCtx<Id, Event, State, FrameMeta>
where Event: Debug,

source§

fn as_ref(&self) -> &FakeInstantCtx

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<Id, Event, State, FrameMeta> AsRef<FakeTimerCtx<Id>> for FakeBindingsCtx<Id, Event, State, FrameMeta>
where Event: Debug,

source§

fn as_ref(&self) -> &FakeTimerCtx<Id>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<TimerId, Event, State, FrameMeta> ContextProvider for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
where Event: Debug,

§

type Context = FakeBindingsCtx<TimerId, Event, State, FrameMeta>

The context provided by this ContextProvider.
source§

fn context( &mut self ) -> &mut <FakeBindingsCtx<TimerId, Event, State, FrameMeta> as ContextProvider>::Context

Gets a mutable borrow to this context.
source§

impl<TimerId, Event, State, FrameMeta> Default for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
where Event: Debug, State: Default,

source§

fn default() -> FakeBindingsCtx<TimerId, Event, State, FrameMeta>

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

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,

Defers the removal of some resource T to bindings. Read more
source§

fn defer_removal_result<T>( &mut self, result: RemoveResourceResult<T, Self::ReferenceReceiver<T>> )
where T: Send + 'static,

A shorthand for [defer_removal] that takes a ReferenceReceiver from the Deferred variant of a RemoveResourceResult. Read more
source§

impl<Id, Event, State, FrameMeta> EventContext<Event> for FakeBindingsCtx<Id, Event, State, FrameMeta>
where Event: Debug,

source§

fn on_event(&mut self, event: Event)

Handles event.
source§

impl<TimerId, Event, State, FrameMeta> FilterBindingsTypes for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
where TimerId: Debug + PartialEq + Clone + Send + Sync, Event: Debug,

§

type DeviceClass = ()

The device class type for devices installed in the netstack.
source§

impl<D: LinkDevice, Id, Event: Debug, State, FrameMeta> LinkResolutionContext<D> for FakeBindingsCtx<Id, Event, State, FrameMeta>

§

type Notifier = FakeLinkResolutionNotifier<D>

A notifier held by core that can be used to inform interested parties of the result of link address resolution.
source§

impl<Id, Event, State, FrameMeta> ReferenceNotifiers for FakeBindingsCtx<Id, Event, State, FrameMeta>
where Event: Debug,

§

type ReferenceReceiver<T: 'static> = Infallible

The receiver for shared reference destruction notifications.
§

type ReferenceNotifier<T: Send + 'static> = Infallible

The notifier for shared reference destruction notifications.
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,

Creates a new Notifier/Receiver pair for T. Read more
source§

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

The random number generator (RNG) provided by this RngContext. Read more
source§

fn rng( &mut self ) -> <FakeBindingsCtx<TimerId, Event, State, FrameMeta> as RngContext>::Rng<'_>

Gets the random number generator (RNG).
source§

impl<Id, Event, State, FrameMeta> TimerBindingsTypes for FakeBindingsCtx<Id, Event, State, FrameMeta>
where Id: Debug + PartialEq + Clone + Send + Sync, Event: Debug,

§

type Timer = <FakeTimerCtx<Id> as TimerBindingsTypes>::Timer

State for a timer created through TimerContext.
§

type DispatchId = <FakeTimerCtx<Id> as TimerBindingsTypes>::DispatchId

The type used to dispatch fired timers from bindings to core.
source§

impl<Id, Event, State, FrameMeta> TimerContext for FakeBindingsCtx<Id, Event, State, FrameMeta>
where Id: Debug + PartialEq + Clone + Send + Sync, Event: Debug,

source§

fn new_timer( &mut self, id: <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::DispatchId ) -> <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::Timer

Creates a new timer that dispatches id back to core when fired. Read more
source§

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>

Schedule a timer to fire at some point in the future. Returns the previously scheduled instant, if this timer was scheduled.
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>

Cancel a timer. Read more
source§

fn scheduled_instant( &self, timer: &mut <FakeBindingsCtx<Id, Event, State, FrameMeta> as TimerBindingsTypes>::Timer ) -> Option<<FakeBindingsCtx<Id, Event, State, FrameMeta> as InstantBindingsTypes>::Instant>

Get the instant a timer will fire, if one is scheduled.
source§

fn schedule_timer( &mut self, duration: Duration, timer: &mut Self::Timer ) -> Option<Self::Instant>

Like [schedule_timer_instant] but schedules a time for duration in the future.
source§

impl<Id, Event, State, FrameMeta> TracingContext for FakeBindingsCtx<Id, Event, State, FrameMeta>
where Event: Debug,

§

type DurationScope = ()

The scope of a trace duration. Read more
source§

fn duration(&self, _: &'static CStr)

Writes a duration event which ends when the returned scope is dropped. Read more
source§

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) -> O
where F: FnOnce(&FakeTimerCtx<TimerId>) -> O,

Calls the callback with a borrow of FakeTimerCtx.
source§

fn with_fake_timer_ctx_mut<O, F>(&mut self, f: F) -> O
where F: FnOnce(&mut FakeTimerCtx<TimerId>) -> O,

Calls the callback with a mutable borrow of 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>
where State: Send, Event: Send, FrameMeta: Send, TimerId: Send,

§

impl<TimerId, Event, State, FrameMeta> !Sync for FakeBindingsCtx<TimerId, Event, State, FrameMeta>

§

impl<TimerId, Event, State, FrameMeta> Unpin for FakeBindingsCtx<TimerId, Event, State, FrameMeta>
where State: Unpin, Event: Unpin, FrameMeta: Unpin, TimerId: Unpin,

§

impl<TimerId, Event, State, FrameMeta> !UnwindSafe for FakeBindingsCtx<TimerId, Event, State, FrameMeta>

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.

source§

impl<T> InstantBindingsTypes for T

§

type Instant = FakeInstant

The type of an instant in time. Read more
source§

impl<T> InstantContext for T

source§

fn now(&self) -> FakeInstant

Returns the current instant. Read more
§

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<CC, BC, Meta> RecvFrameContext<BC, Meta> for CC
where Meta: ReceivableFrameMeta<CC, BC>,

source§

fn receive_frame<B>(&mut self, bindings_ctx: &mut BC, metadata: Meta, frame: B)
where B: BufferMut + Debug,

Receive a frame. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<CC, BC, Meta> SendFrameContext<BC, Meta> for CC
where Meta: SendableFrameMeta<CC, BC>,

source§

fn send_frame<S>( &mut self, bindings_ctx: &mut BC, metadata: Meta, frame: S ) -> Result<(), S>
where S: Serializer, <S as Serializer>::Buffer: BufferMut,

Send a frame. Read more
source§

impl<Meta, BC> SendableFrameMeta<FakeFrameCtx<Meta>, BC> for Meta

source§

fn send_meta<S>( self, core_ctx: &mut FakeFrameCtx<Meta>, _bindings_ctx: &mut BC, frame: S ) -> Result<(), S>
where S: Serializer, <S as Serializer>::Buffer: BufferMut,

Sends this frame metadata to the provided contexts.
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, 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<BC> FilterBindingsContext for BC

source§

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