Struct netstack3_core::testutil::FakeBindingsCtx
source · pub struct FakeBindingsCtx(/* private fields */);
Expand description
Test-only implementation of crate::BindingsContext
.
Implementations§
source§impl FakeBindingsCtx
impl FakeBindingsCtx
sourcepub fn take_ethernet_frames(
&mut self
) -> Vec<(EthernetWeakDeviceId<FakeBindingsCtx>, Vec<u8>)>
pub fn take_ethernet_frames( &mut self ) -> Vec<(EthernetWeakDeviceId<FakeBindingsCtx>, Vec<u8>)>
sourcepub fn take_ip_frames(
&mut self
) -> Vec<(PureIpDeviceAndIpVersion<FakeBindingsCtx>, Vec<u8>)>
pub fn take_ip_frames( &mut self ) -> Vec<(PureIpDeviceAndIpVersion<FakeBindingsCtx>, Vec<u8>)>
Trait Implementations§
source§impl Clone for FakeBindingsCtx
impl Clone for FakeBindingsCtx
source§fn clone(&self) -> FakeBindingsCtx
fn clone(&self) -> FakeBindingsCtx
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Default for FakeBindingsCtx
impl Default for FakeBindingsCtx
source§fn default() -> FakeBindingsCtx
fn default() -> FakeBindingsCtx
source§impl DeferredResourceRemovalContext for FakeBindingsCtx
impl DeferredResourceRemovalContext for FakeBindingsCtx
source§fn defer_removal<T: Send + 'static>(
&mut self,
receiver: Self::ReferenceReceiver<T>
)
fn defer_removal<T: Send + 'static>( &mut self, receiver: Self::ReferenceReceiver<T> )
T
to bindings. Read moresource§fn defer_removal_result<T>(
&mut self,
result: RemoveResourceResult<T, Self::ReferenceReceiver<T>>
)where
T: Send + 'static,
fn defer_removal_result<T>(
&mut self,
result: RemoveResourceResult<T, Self::ReferenceReceiver<T>>
)where
T: Send + 'static,
defer_removal
] that takes a ReferenceReceiver
from
the Deferred
variant of a RemoveResourceResult
. Read moresource§impl DeviceLayerEventDispatcher for FakeBindingsCtx
impl DeviceLayerEventDispatcher for FakeBindingsCtx
source§fn wake_rx_task(&mut self, device: &LoopbackDeviceId<FakeBindingsCtx>)
fn wake_rx_task(&mut self, device: &LoopbackDeviceId<FakeBindingsCtx>)
handle_queued_rx_packets
]. Read moresource§fn wake_tx_task(&mut self, device: &DeviceId<FakeBindingsCtx>)
fn wake_tx_task(&mut self, device: &DeviceId<FakeBindingsCtx>)
transmit_queued_tx_frames
]. Read moresource§fn send_ethernet_frame(
&mut self,
device: &EthernetDeviceId<FakeBindingsCtx>,
frame: Buf<Vec<u8>>
) -> Result<(), DeviceSendFrameError<Buf<Vec<u8>>>>
fn send_ethernet_frame( &mut self, device: &EthernetDeviceId<FakeBindingsCtx>, frame: Buf<Vec<u8>> ) -> Result<(), DeviceSendFrameError<Buf<Vec<u8>>>>
source§fn send_ip_packet(
&mut self,
device: &PureIpDeviceId<FakeBindingsCtx>,
packet: Buf<Vec<u8>>,
ip_version: IpVersion
) -> Result<(), DeviceSendFrameError<Buf<Vec<u8>>>>
fn send_ip_packet( &mut self, device: &PureIpDeviceId<FakeBindingsCtx>, packet: Buf<Vec<u8>>, ip_version: IpVersion ) -> Result<(), DeviceSendFrameError<Buf<Vec<u8>>>>
source§impl DeviceLayerStateTypes for FakeBindingsCtx
impl DeviceLayerStateTypes for FakeBindingsCtx
§type LoopbackDeviceState = ()
type LoopbackDeviceState = ()
§type EthernetDeviceState = ()
type EthernetDeviceState = ()
§type PureIpDeviceState = ()
type PureIpDeviceState = ()
§type DeviceIdentifier = MonotonicIdentifier
type DeviceIdentifier = MonotonicIdentifier
source§impl DeviceSocketBindingsContext<DeviceId<FakeBindingsCtx>> for FakeBindingsCtx
impl DeviceSocketBindingsContext<DeviceId<FakeBindingsCtx>> for FakeBindingsCtx
source§fn receive_frame(
&self,
state: &Self::SocketState,
device: &DeviceId<Self>,
_frame: Frame<&[u8]>,
raw_frame: &[u8]
)
fn receive_frame( &self, state: &Self::SocketState, device: &DeviceId<Self>, _frame: Frame<&[u8]>, raw_frame: &[u8] )
source§impl DeviceSocketTypes for FakeBindingsCtx
impl DeviceSocketTypes for FakeBindingsCtx
§type SocketState = Mutex<Vec<(WeakDeviceId<FakeBindingsCtx>, Vec<u8>)>>
type SocketState = Mutex<Vec<(WeakDeviceId<FakeBindingsCtx>, Vec<u8>)>>
source§impl<T: Into<DispatchedEvent>> EventContext<T> for FakeBindingsCtx
impl<T: Into<DispatchedEvent>> EventContext<T> for FakeBindingsCtx
source§impl FilterBindingsTypes for FakeBindingsCtx
impl FilterBindingsTypes for FakeBindingsCtx
§type DeviceClass = ()
type DeviceClass = ()
source§impl<I: IpExt> IcmpEchoBindingsContext<I, DeviceId<FakeBindingsCtx>> for FakeBindingsCtx
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
)
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 )
source§impl IcmpEchoBindingsTypes for FakeBindingsCtx
impl IcmpEchoBindingsTypes for FakeBindingsCtx
§type ExternalData<I: Ip> = ()
type ExternalData<I: Ip> = ()
source§impl InstantBindingsTypes for FakeBindingsCtx
impl InstantBindingsTypes for FakeBindingsCtx
§type Instant = FakeInstant
type Instant = FakeInstant
source§impl InstantContext for FakeBindingsCtx
impl InstantContext for FakeBindingsCtx
source§fn now(&self) -> FakeInstant
fn now(&self) -> FakeInstant
source§impl<D: LinkDevice> LinkResolutionContext<D> for FakeBindingsCtx
impl<D: LinkDevice> LinkResolutionContext<D> for FakeBindingsCtx
source§impl ReferenceNotifiers for FakeBindingsCtx
impl ReferenceNotifiers for FakeBindingsCtx
§type ReferenceReceiver<T: 'static> = Infallible
type ReferenceReceiver<T: 'static> = Infallible
§type ReferenceNotifier<T: Send + 'static> = Infallible
type ReferenceNotifier<T: Send + 'static> = Infallible
source§fn new_reference_notifier<T: Send + 'static>(
debug_references: DynDebugReferences
) -> (Self::ReferenceNotifier<T>, Self::ReferenceReceiver<T>)
fn new_reference_notifier<T: Send + 'static>( debug_references: DynDebugReferences ) -> (Self::ReferenceNotifier<T>, Self::ReferenceReceiver<T>)
T
. Read moresource§impl RngContext for FakeBindingsCtx
impl RngContext for FakeBindingsCtx
§type Rng<'a> = FakeCryptoRng<XorShiftRng>
type Rng<'a> = FakeCryptoRng<XorShiftRng>
RngContext
. Read moresource§impl TcpBindingsTypes for FakeBindingsCtx
impl TcpBindingsTypes for FakeBindingsCtx
§type ReceiveBuffer = Arc<Mutex<RingBuffer>>
type ReceiveBuffer = Arc<Mutex<RingBuffer>>
§type SendBuffer = TestSendBuffer
type SendBuffer = TestSendBuffer
§type ReturnedBuffers = ClientBuffers
type ReturnedBuffers = ClientBuffers
§type ListenerNotifierOrProvidedBuffers = ProvidedBuffers
type ListenerNotifierOrProvidedBuffers = ProvidedBuffers
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)
fn new_passive_open_buffers( buffer_sizes: BufferSizes ) -> (Self::ReceiveBuffer, Self::SendBuffer, Self::ReturnedBuffers)
source§fn default_buffer_sizes() -> BufferSizes
fn default_buffer_sizes() -> BufferSizes
source§impl TimerBindingsTypes for FakeBindingsCtx
impl TimerBindingsTypes for FakeBindingsCtx
§type Timer = <FakeTimerCtx<TimerId<FakeBindingsCtx>> as TimerBindingsTypes>::Timer
type Timer = <FakeTimerCtx<TimerId<FakeBindingsCtx>> as TimerBindingsTypes>::Timer
TimerContext
.§type DispatchId = TimerId<FakeBindingsCtx>
type DispatchId = TimerId<FakeBindingsCtx>
source§impl TimerContext for FakeBindingsCtx
impl TimerContext for FakeBindingsCtx
source§fn new_timer(&mut self, id: Self::DispatchId) -> Self::Timer
fn new_timer(&mut self, id: Self::DispatchId) -> Self::Timer
id
back to core when fired. Read moresource§fn schedule_timer_instant(
&mut self,
time: Self::Instant,
timer: &mut Self::Timer
) -> Option<Self::Instant>
fn schedule_timer_instant( &mut self, time: Self::Instant, timer: &mut Self::Timer ) -> Option<Self::Instant>
source§fn cancel_timer(&mut self, timer: &mut Self::Timer) -> Option<Self::Instant>
fn cancel_timer(&mut self, timer: &mut Self::Timer) -> Option<Self::Instant>
source§impl TracingContext for FakeBindingsCtx
impl TracingContext for FakeBindingsCtx
source§impl UdpBindingsTypes for FakeBindingsCtx
impl UdpBindingsTypes for FakeBindingsCtx
§type ExternalData<I: Ip> = ()
type ExternalData<I: Ip> = ()
source§impl<I: IpExt> UdpReceiveBindingsContext<I, DeviceId<FakeBindingsCtx>> for FakeBindingsCtx
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
)
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 )
source§impl WithFakeTimerContext<TimerId<FakeBindingsCtx>> for FakeBindingsCtx
impl WithFakeTimerContext<TimerId<FakeBindingsCtx>> for FakeBindingsCtx
source§fn with_fake_timer_ctx<O, F: FnOnce(&FakeTimerCtx<TimerId<FakeBindingsCtx>>) -> O>(
&self,
f: F
) -> O
fn with_fake_timer_ctx<O, F: FnOnce(&FakeTimerCtx<TimerId<FakeBindingsCtx>>) -> O>( &self, f: F ) -> O
FakeTimerCtx
.source§fn with_fake_timer_ctx_mut<O, F: FnOnce(&mut FakeTimerCtx<TimerId<FakeBindingsCtx>>) -> O>(
&mut self,
f: F
) -> O
fn with_fake_timer_ctx_mut<O, F: FnOnce(&mut FakeTimerCtx<TimerId<FakeBindingsCtx>>) -> O>( &mut self, f: F ) -> O
FakeTimerCtx
.Auto Trait Implementations§
impl Freeze for FakeBindingsCtx
impl RefUnwindSafe for FakeBindingsCtx
impl Send for FakeBindingsCtx
impl Sync for FakeBindingsCtx
impl Unpin for FakeBindingsCtx
impl UnwindSafe for FakeBindingsCtx
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).