Struct FakeCoreCtx

Source
pub struct FakeCoreCtx<S, Meta, DeviceId> {
    pub state: S,
    pub frames: FakeFrameCtx<Meta>,
    /* private fields */
}
Expand description

A test helper used to provide an implementation of a core context.

Fields§

§state: S

Generic state kept in this fake context.

§frames: FakeFrameCtx<Meta>

A fake frame context for outgoing frames.

Implementations§

Source§

impl<S, Meta, DeviceId> FakeCoreCtx<S, Meta, DeviceId>

Source

pub fn with_state(state: S) -> Self

Constructs a FakeCoreCtx with the given state and default FakeTimerCtx, and FakeFrameCtx.

Source

pub fn frames(&self) -> &[(Meta, Vec<u8>)]

Get the list of frames sent so far.

Source

pub fn take_frames(&mut self) -> Vec<(Meta, Vec<u8>)>

Take the list of frames sent so far.

Source

pub fn into_state(self) -> S

Consumes the FakeCoreCtx and returns the inner state.

Trait Implementations§

Source§

impl<S, Meta, DeviceId> AsRef<S> for FakeCoreCtx<S, Meta, DeviceId>

Source§

fn as_ref(&self) -> &S

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

impl<S, Meta, DeviceId> ContextProvider for FakeCoreCtx<S, Meta, DeviceId>

Source§

type Context = FakeCoreCtx<S, Meta, DeviceId>

The context provided by this ContextProvider.
Source§

fn context(&mut self) -> &mut Self::Context

Gets a mutable borrow to this context.
Source§

impl<T, S, Meta, DeviceId, BT> CoreTxMetadataContext<T, BT> for FakeCoreCtx<S, Meta, DeviceId>
where BT: TxMetadataBindingsTypes<TxMetadata = FakeTxMetadata>,

Source§

fn convert_tx_meta(&self, _tx_meta: T) -> FakeTxMetadata

Converts the tx metadata T into the type set by bindings. Read more
Source§

impl<C, S, Meta, DeviceId> CounterContext<C> for FakeCoreCtx<S, Meta, DeviceId>
where S: CounterContext<C>,

Source§

fn counters(&self) -> &C

Returns a reference to the counters.
Source§

impl<S, Meta, DeviceId> Default for FakeCoreCtx<S, Meta, DeviceId>
where S: Default,

Source§

fn default() -> Self

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

impl<S, Meta, D: StrongDeviceIdentifier> DeviceIdContext<AnyDevice> for &mut FakeCoreCtx<S, Meta, D>

Source§

type DeviceId = D

The type of device IDs.
Source§

type WeakDeviceId = <D as StrongDeviceIdentifier>::Weak

The type of weakly referenced device IDs.
Source§

impl<S, Meta, D: StrongDeviceIdentifier> DeviceIdContext<AnyDevice> for FakeCoreCtx<S, Meta, D>

Source§

type DeviceId = D

The type of device IDs.
Source§

type WeakDeviceId = <D as StrongDeviceIdentifier>::Weak

The type of weakly referenced device IDs.
Source§

impl<S, M> DeviceIdContext<FakeLinkDevice> for FakeCoreCtx<S, M, FakeLinkDeviceId>

Source§

type DeviceId = FakeLinkDeviceId

The type of device IDs.
Source§

type WeakDeviceId = FakeWeakDeviceId<FakeLinkDeviceId>

The type of weakly referenced device IDs.
Source§

impl<I: AssignedAddrIpExt, S, Meta, DeviceId: StrongDeviceIdentifier> IpDeviceAddressIdContext<I> for FakeCoreCtx<S, Meta, DeviceId>

Source§

type AddressId = AddrSubnet<<I as Ip>::Addr, <I as AssignedAddrIpExt>::AssignedWitness>

The strong address identifier.
Source§

type WeakAddressId = FakeWeakAddressId<<FakeCoreCtx<S, Meta, DeviceId> as IpDeviceAddressIdContext<I>>::AddressId>

The weak address identifier.
Source§

impl<C, S, R, Meta, DeviceId> ResourceCounterContext<R, C> for FakeCoreCtx<S, Meta, DeviceId>
where S: ResourceCounterContext<R, C>,

Source§

fn per_resource_counters<'a>(&'a self, resource: &'a R) -> &'a C

Returns a reference to the set of counters on resource.
Source§

fn increment_both<F: Fn(&T) -> &Counter>(&self, resource: &R, cb: F)

Increments both the per-resource and stackwide versions of the counter returned by the callback.
Source§

impl<S, Meta, DeviceId> WithFakeFrameContext<Meta> for FakeCoreCtx<S, Meta, DeviceId>

Source§

fn with_fake_frame_ctx_mut<O, F: FnOnce(&mut FakeFrameCtx<Meta>) -> O>( &mut self, f: F, ) -> O

Calls the callback with a mutable reference to the FakeFrameCtx.

Auto Trait Implementations§

§

impl<S, Meta, DeviceId> Freeze for FakeCoreCtx<S, Meta, DeviceId>
where S: Freeze,

§

impl<S, Meta, DeviceId> !RefUnwindSafe for FakeCoreCtx<S, Meta, DeviceId>

§

impl<S, Meta, DeviceId> Send for FakeCoreCtx<S, Meta, DeviceId>
where S: Send, DeviceId: Send, Meta: Send,

§

impl<S, Meta, DeviceId> !Sync for FakeCoreCtx<S, Meta, DeviceId>

§

impl<S, Meta, DeviceId> Unpin for FakeCoreCtx<S, Meta, DeviceId>
where S: Unpin, DeviceId: Unpin, Meta: Unpin,

§

impl<S, Meta, DeviceId> !UnwindSafe for FakeCoreCtx<S, Meta, DeviceId>

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<O, BC> BuildableCoreContext<BC> for O
where O: Default,

Source§

type Builder = ()

The builder type that can build this core context.
Source§

fn build(_bindings_ctx: &mut BC, _: ()) -> O

Consumes this builder and returns the context.
§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<CC, BC, Meta> RecvFrameContext<Meta, BC> 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<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<(), ErrorAndSerializer<SendFrameErrorReason, S>>

Send a frame. Read more
Source§

impl<BC, S, Meta, DeviceId> SendableFrameMeta<FakeCoreCtx<S, Meta, DeviceId>, BC> for Meta

Source§

fn send_meta<SS>( self, core_ctx: &mut FakeCoreCtx<S, Meta, DeviceId>, bindings_ctx: &mut BC, frame: SS, ) -> Result<(), ErrorAndSerializer<SendFrameErrorReason, SS>>
where SS: Serializer, <SS as Serializer>::Buffer: BufferMut,

Sends this frame metadata to the provided contexts.
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<(), ErrorAndSerializer<SendFrameErrorReason, S>>

Sends this frame metadata to the provided contexts.
Source§

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

Source§

fn handle_timer( &mut self, bindings_ctx: &mut BC, dispatch: Id, timer: <BC as TimerBindingsTypes>::UniqueTimerId, )

Handle a timer firing. Read more
Source§

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

Source§

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

Source§

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<L, T> UnlockedAccess<L> for T
where L: UnlockedAccessMarkerFor<T>,

§

type Data = <L as UnlockedAccessMarkerFor<T>>::Data

The type of state being accessed.
§

type Guard<'l> = &'l <L as UnlockedAccessMarkerFor<T>>::Data where T: 'l

A guard providing read access to the data.
§

fn access(&self) -> <T as UnlockedAccess<L>>::Guard<'_>

How to access the state.
Source§

impl<N> UnreachableExt for N
where N: AsRef<Infallible>,

Source§

fn uninstantiable_unreachable<T>(&self) -> T

A method that can’t be called. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<CC, D> DeviceIdAnyCompatContext<D> for CC

§

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