pub struct FakeBindingsCtx(/* private fields */);
Expand description

Test-only implementation of crate::BindingsContext.

Implementations§

source§

impl FakeBindingsCtx

source

pub fn take_ethernet_frames( &mut self ) -> Vec<(EthernetWeakDeviceId<FakeBindingsCtx>, Vec<u8>)>

Take all ethernet frames sent so far.

§Panics

Panics if the there are non-Ethernet frames stored.

source

pub fn take_ip_frames( &mut self ) -> Vec<(PureIpDeviceAndIpVersion<FakeBindingsCtx>, Vec<u8>)>

Take all IP frames sent so far.

§Panics

Panics if the there are non-IP frames stored.

Trait Implementations§

source§

impl Clone for FakeBindingsCtx

source§

fn clone(&self) -> FakeBindingsCtx

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 Default for FakeBindingsCtx

source§

fn default() -> FakeBindingsCtx

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

impl DeferredResourceRemovalContext for FakeBindingsCtx

source§

fn defer_removal<T: Send + 'static>( &mut self, receiver: Self::ReferenceReceiver<T> )

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 DeviceLayerEventDispatcher for FakeBindingsCtx

source§

fn wake_rx_task(&mut self, device: &LoopbackDeviceId<FakeBindingsCtx>)

Signals to the dispatcher that RX frames are available and ready to be handled by [handle_queued_rx_packets]. Read more
source§

fn wake_tx_task(&mut self, device: &DeviceId<FakeBindingsCtx>)

Signals to the dispatcher that TX frames are available and ready to be sent by [transmit_queued_tx_frames]. Read more
source§

fn send_ethernet_frame( &mut self, device: &EthernetDeviceId<FakeBindingsCtx>, frame: Buf<Vec<u8>> ) -> Result<(), DeviceSendFrameError<Buf<Vec<u8>>>>

Send a frame to an Ethernet device driver. Read more
source§

fn send_ip_packet( &mut self, device: &PureIpDeviceId<FakeBindingsCtx>, packet: Buf<Vec<u8>>, ip_version: IpVersion ) -> Result<(), DeviceSendFrameError<Buf<Vec<u8>>>>

Send an IP packet to an IP device driver. Read more
source§

impl DeviceLayerStateTypes for FakeBindingsCtx

§

type LoopbackDeviceState = ()

The state associated with loopback devices.
§

type EthernetDeviceState = ()

The state associated with ethernet devices.
§

type PureIpDeviceState = ()

The state associated with pure IP devices.
§

type DeviceIdentifier = MonotonicIdentifier

An opaque identifier that is available from both strong and weak device references.
source§

impl DeviceSocketBindingsContext<DeviceId<FakeBindingsCtx>> for FakeBindingsCtx

source§

fn receive_frame( &self, state: &Self::SocketState, device: &DeviceId<Self>, _frame: Frame<&[u8]>, raw_frame: &[u8] )

Called for each received frame that matches the provided socket. Read more
source§

impl DeviceSocketTypes for FakeBindingsCtx

§

type SocketState = Mutex<Vec<(WeakDeviceId<FakeBindingsCtx>, Vec<u8>)>>

State for the socket held by core and exposed to bindings.
source§

impl<T: Into<DispatchedEvent>> EventContext<T> for FakeBindingsCtx

source§

fn on_event(&mut self, event: T)

Handles event.
source§

impl FilterBindingsTypes for FakeBindingsCtx

§

type DeviceClass = ()

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

impl<I: IpExt> IcmpEchoBindingsContext<I, DeviceId<FakeBindingsCtx>> for FakeBindingsCtx

source§

fn receive_icmp_echo_reply<B: BufferMut>( &mut self, conn: &IcmpSocketId<I, WeakDeviceId<FakeBindingsCtx>, FakeBindingsCtx>, _device: &DeviceId<Self>, _src_ip: I::Addr, _dst_ip: I::Addr, _id: u16, data: B )

Receives an ICMP echo reply.
source§

impl IcmpEchoBindingsTypes for FakeBindingsCtx

§

type ExternalData<I: Ip> = ()

Opaque bindings data held by core for a given IP version.
source§

impl InstantBindingsTypes for FakeBindingsCtx

§

type Instant = FakeInstant

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

impl InstantContext for FakeBindingsCtx

source§

fn now(&self) -> FakeInstant

Returns the current instant. Read more
source§

impl<D: LinkDevice> LinkResolutionContext<D> for FakeBindingsCtx

§

type Notifier = ()

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

impl ReferenceNotifiers for FakeBindingsCtx

§

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: Send + 'static>( debug_references: DynDebugReferences ) -> (Self::ReferenceNotifier<T>, Self::ReferenceReceiver<T>)

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

impl RngContext for FakeBindingsCtx

§

type Rng<'a> = FakeCryptoRng<XorShiftRng>

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

fn rng(&mut self) -> Self::Rng<'_>

Gets the random number generator (RNG).
source§

impl TcpBindingsTypes for FakeBindingsCtx

§

type ReceiveBuffer = Arc<Mutex<RingBuffer>>

Receive buffer used by TCP.
§

type SendBuffer = TestSendBuffer

Send buffer used by TCP.
§

type ReturnedBuffers = ClientBuffers

The object that will be returned by the state machine when a passive open connection becomes established. The bindings can use this object to read/write bytes from/into the created buffers.
§

type ListenerNotifierOrProvidedBuffers = ProvidedBuffers

The extra information provided by the Bindings that implements platform dependent behaviors. It serves as a ListenerNotifier if the socket was used as a listener and it will be used to provide buffers if used to establish connections.
source§

fn new_passive_open_buffers( buffer_sizes: BufferSizes ) -> (Self::ReceiveBuffer, Self::SendBuffer, Self::ReturnedBuffers)

Creates new buffers and returns the object that Bindings need to read/write from/into the created buffers.
source§

fn default_buffer_sizes() -> BufferSizes

The buffer sizes to use when creating new sockets.
source§

impl TimerBindingsTypes for FakeBindingsCtx

§

type Timer = <FakeTimerCtx<TimerId<FakeBindingsCtx>> as TimerBindingsTypes>::Timer

State for a timer created through TimerContext.
§

type DispatchId = TimerId<FakeBindingsCtx>

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

impl TimerContext for FakeBindingsCtx

source§

fn new_timer(&mut self, id: Self::DispatchId) -> Self::Timer

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

fn schedule_timer_instant( &mut self, time: Self::Instant, timer: &mut Self::Timer ) -> Option<Self::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 Self::Timer) -> Option<Self::Instant>

Cancel a timer. Read more
source§

fn scheduled_instant(&self, timer: &mut Self::Timer) -> Option<Self::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 TracingContext for FakeBindingsCtx

§

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 UdpBindingsTypes for FakeBindingsCtx

§

type ExternalData<I: Ip> = ()

Opaque bindings data held by core for a given IP version.
source§

impl<I: IpExt> UdpReceiveBindingsContext<I, DeviceId<FakeBindingsCtx>> for FakeBindingsCtx

source§

fn receive_udp<B: BufferMut>( &mut self, id: &UdpSocketId<I, WeakDeviceId<Self>, FakeBindingsCtx>, _device: &DeviceId<Self>, _dst_addr: (I::Addr, NonZeroU16), _src_addr: (I::Addr, Option<NonZeroU16>), body: &B )

Receives a UDP packet on a socket.
source§

impl WithFakeTimerContext<TimerId<FakeBindingsCtx>> for FakeBindingsCtx

source§

fn with_fake_timer_ctx<O, F: FnOnce(&FakeTimerCtx<TimerId<FakeBindingsCtx>>) -> O>( &self, f: F ) -> O

Calls the callback with a borrow of FakeTimerCtx.
source§

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

Calls the callback with a mutable borrow of FakeTimerCtx.

Auto Trait Implementations§

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<BC> BindingsContext for BC

source§

impl<O> BindingsTypes for O
where O: InstantBindingsTypes + DeviceLayerTypes<DispatchId = TimerId<O>> + TcpBindingsTypes + FilterBindingsTypes + IcmpBindingsTypes + UdpBindingsTypes + TimerBindingsTypes,

source§

impl<BC> FilterBindingsContext for BC

source§

impl<I, BC> IpBindingsContext<I> for BC
where I: IpExt, BC: BindingsTypes + RngContext + UdpBindingsContext<I, DeviceId<BC>> + TcpBindingsContext + FilterBindingsContext + IcmpBindingsContext<I, DeviceId<BC>> + IpDeviceBindingsContext<I, DeviceId<BC>> + IpLayerBindingsContext<I, DeviceId<BC>> + NudBindingsContext<I, EthernetLinkDevice, BaseDeviceId<EthernetLinkDevice, BC>> + DeviceLayerEventDispatcher + DeviceSocketBindingsContext<DeviceId<BC>> + ReferenceNotifiers + TracingContext + 'static,

source§

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