pub struct FakeBindingsCtx(/* private fields */);Expand description
Test-only implementation of BindingsContext.
Implementations§
Source§impl FakeBindingsCtx
impl FakeBindingsCtx
Sourcepub fn timer_ctx(&self) -> impl Deref<Target = FakeTimerCtx<TimerId<Self>>> + '_
pub fn timer_ctx(&self) -> impl Deref<Target = FakeTimerCtx<TimerId<Self>>> + '_
Gets the fake timer context.
Sourcepub fn state_mut(&mut self) -> impl DerefMut<Target = FakeBindingsCtxState> + '_
pub fn state_mut(&mut self) -> impl DerefMut<Target = FakeBindingsCtxState> + '_
Returns a mutable reference guard to FakeBindingsCtxState.
Sourcepub fn copy_ethernet_frames(
&mut self,
) -> Vec<(EthernetWeakDeviceId<FakeBindingsCtx>, Vec<u8>)>
pub fn copy_ethernet_frames( &mut self, ) -> Vec<(EthernetWeakDeviceId<FakeBindingsCtx>, Vec<u8>)>
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>)>
Sourcepub fn take_events(&mut self) -> Vec<DispatchedEvent>
pub fn take_events(&mut self) -> Vec<DispatchedEvent>
Takes all the events stored in the fake context.
Sourcepub fn take_icmp_replies<I: IpExt>(
&mut self,
conn: &IcmpSocketId<I, WeakDeviceId<FakeBindingsCtx>, FakeBindingsCtx>,
) -> Vec<Vec<u8>>
pub fn take_icmp_replies<I: IpExt>( &mut self, conn: &IcmpSocketId<I, WeakDeviceId<FakeBindingsCtx>, FakeBindingsCtx>, ) -> Vec<Vec<u8>>
Takes all the received ICMP replies for a given conn.
Sourcepub fn take_udp_received<I: IpExt>(
&mut self,
conn: &UdpSocketId<I, WeakDeviceId<FakeBindingsCtx>, FakeBindingsCtx>,
) -> Vec<Vec<u8>>
pub fn take_udp_received<I: IpExt>( &mut self, conn: &UdpSocketId<I, WeakDeviceId<FakeBindingsCtx>, FakeBindingsCtx>, ) -> Vec<Vec<u8>>
Takes all received UDP frames from the fake bindings context.
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§type DequeueContext = ()
type DequeueContext = ()
Source§fn send_ethernet_frame(
&mut self,
device: &EthernetDeviceId<FakeBindingsCtx>,
frame: Buf<Vec<u8>>,
_dequeue_context: Option<&mut Self::DequeueContext>,
) -> Result<(), DeviceSendFrameError>
fn send_ethernet_frame( &mut self, device: &EthernetDeviceId<FakeBindingsCtx>, frame: Buf<Vec<u8>>, _dequeue_context: Option<&mut Self::DequeueContext>, ) -> Result<(), DeviceSendFrameError>
Source§fn send_ip_packet(
&mut self,
device: &PureIpDeviceId<FakeBindingsCtx>,
packet: Buf<Vec<u8>>,
ip_version: IpVersion,
_dequeue_context: Option<&mut Self::DequeueContext>,
) -> Result<(), DeviceSendFrameError>
fn send_ip_packet( &mut self, device: &PureIpDeviceId<FakeBindingsCtx>, packet: Buf<Vec<u8>>, ip_version: IpVersion, _dequeue_context: Option<&mut Self::DequeueContext>, ) -> Result<(), DeviceSendFrameError>
Source§impl DeviceLayerStateTypes for FakeBindingsCtx
impl DeviceLayerStateTypes for FakeBindingsCtx
Source§type LoopbackDeviceState = ()
type LoopbackDeviceState = ()
Source§type EthernetDeviceState = ()
type EthernetDeviceState = ()
Source§type BlackholeDeviceState = ()
type BlackholeDeviceState = ()
Source§type PureIpDeviceState = ()
type PureIpDeviceState = ()
Source§type DeviceIdentifier = MonotonicIdentifier
type DeviceIdentifier = MonotonicIdentifier
Source§impl DeviceSocketTypes for FakeBindingsCtx
impl DeviceSocketTypes for FakeBindingsCtx
Source§type SocketState<D: Send + Sync + Debug> = Mutex<Vec<(WeakDeviceId<FakeBindingsCtx>, Vec<u8>)>>
type SocketState<D: Send + Sync + Debug> = 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<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,
) -> Result<(), ReceiveIcmpEchoError>
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, ) -> Result<(), ReceiveIcmpEchoError>
Source§impl IcmpEchoBindingsTypes for FakeBindingsCtx
impl IcmpEchoBindingsTypes for FakeBindingsCtx
Source§type ExternalData<I: Ip> = ()
type ExternalData<I: Ip> = ()
Source§type SocketWritableListener = FakeSocketWritableListener
type SocketWritableListener = FakeSocketWritableListener
Source§impl InstantBindingsTypes for FakeBindingsCtx
impl InstantBindingsTypes for FakeBindingsCtx
Source§type Instant = FakeInstant
type Instant = FakeInstant
Source§type AtomicInstant = FakeAtomicInstant
type AtomicInstant = FakeAtomicInstant
Self::Instant.Source§impl InstantContext for FakeBindingsCtx
impl InstantContext for FakeBindingsCtx
Source§fn now(&self) -> FakeInstant
fn now(&self) -> FakeInstant
Source§fn now_atomic(&self) -> Self::AtomicInstant
fn now_atomic(&self) -> Self::AtomicInstant
Self::AtomicInstant].Source§impl IpRoutingBindingsTypes for FakeBindingsCtx
impl IpRoutingBindingsTypes for FakeBindingsCtx
Source§type RoutingTableId = ()
type RoutingTableId = ()
Source§impl<D: LinkDevice> LinkResolutionContext<D> for FakeBindingsCtx
impl<D: LinkDevice> LinkResolutionContext<D> for FakeBindingsCtx
Source§type Notifier = NoOpLinkResolutionNotifier
type Notifier = NoOpLinkResolutionNotifier
Source§impl MatcherBindingsTypes for FakeBindingsCtx
impl MatcherBindingsTypes for FakeBindingsCtx
Source§type DeviceClass = ()
type DeviceClass = ()
Source§type BindingsPacketMatcher = Infallible
type BindingsPacketMatcher = Infallible
Source§impl<I: IpExt> RawIpSocketsBindingsContext<I, DeviceId<FakeBindingsCtx>> for FakeBindingsCtx
impl<I: IpExt> RawIpSocketsBindingsContext<I, DeviceId<FakeBindingsCtx>> for FakeBindingsCtx
Source§fn receive_packet<B: SplitByteSlice>(
&self,
_socket: &RawIpSocketId<I, WeakDeviceId<Self>, Self>,
_packet: &I::Packet<B>,
_device: &DeviceId<Self>,
) -> Result<(), ReceivePacketError>
fn receive_packet<B: SplitByteSlice>( &self, _socket: &RawIpSocketId<I, WeakDeviceId<Self>, Self>, _packet: &I::Packet<B>, _device: &DeviceId<Self>, ) -> Result<(), ReceivePacketError>
Source§impl RawIpSocketsBindingsTypes for FakeBindingsCtx
impl RawIpSocketsBindingsTypes for FakeBindingsCtx
Source§type RawIpSocketState<I: Ip> = ()
type RawIpSocketState<I: Ip> = ()
Source§impl ReceiveQueueBindingsContext<BaseDeviceId<LoopbackDevice, FakeBindingsCtx>> for FakeBindingsCtx
impl ReceiveQueueBindingsContext<BaseDeviceId<LoopbackDevice, FakeBindingsCtx>> for FakeBindingsCtx
Source§fn wake_rx_task(&mut self, device: &LoopbackDeviceId<FakeBindingsCtx>)
fn wake_rx_task(&mut self, device: &LoopbackDeviceId<FakeBindingsCtx>)
Source§impl ReferenceNotifiers for FakeBindingsCtx
impl ReferenceNotifiers for FakeBindingsCtx
Source§type ReferenceReceiver<T: 'static> = Infallible
type ReferenceReceiver<T: 'static> = Infallible
Source§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
Source§impl SocketOpsFilterBindingContext<DeviceId<FakeBindingsCtx>> for FakeBindingsCtx
impl SocketOpsFilterBindingContext<DeviceId<FakeBindingsCtx>> for FakeBindingsCtx
Source§fn socket_ops_filter(&self) -> impl SocketOpsFilter<DeviceId<FakeBindingsCtx>>
fn socket_ops_filter(&self) -> impl SocketOpsFilter<DeviceId<FakeBindingsCtx>>
Source§impl TcpBindingsTypes for FakeBindingsCtx
impl TcpBindingsTypes for FakeBindingsCtx
Source§type ReceiveBuffer = Arc<Mutex<RingBuffer>>
type ReceiveBuffer = Arc<Mutex<RingBuffer>>
Source§type SendBuffer = TestSendBuffer
type SendBuffer = TestSendBuffer
Source§type ReturnedBuffers = ClientBuffers
type ReturnedBuffers = ClientBuffers
Source§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§impl TimerBindingsTypes for FakeBindingsCtx
impl TimerBindingsTypes for FakeBindingsCtx
Source§type Timer = <FakeTimerCtx<TimerId<FakeBindingsCtx>> as TimerBindingsTypes>::Timer
type Timer = <FakeTimerCtx<TimerId<FakeBindingsCtx>> as TimerBindingsTypes>::Timer
TimerContext.Source§type DispatchId = TimerId<FakeBindingsCtx>
type DispatchId = TimerId<FakeBindingsCtx>
Source§type UniqueTimerId = <FakeTimerCtx<TimerId<FakeBindingsCtx>> as TimerBindingsTypes>::UniqueTimerId
type UniqueTimerId = <FakeTimerCtx<TimerId<FakeBindingsCtx>> as TimerBindingsTypes>::UniqueTimerId
Timer. It is given along with the
DispatchId whenever a timer is fired. Read moreSource§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§fn scheduled_instant(&self, timer: &mut Self::Timer) -> Option<Self::Instant>
fn scheduled_instant(&self, timer: &mut Self::Timer) -> Option<Self::Instant>
Source§fn unique_timer_id(&self, timer: &Self::Timer) -> Self::UniqueTimerId
fn unique_timer_id(&self, timer: &Self::Timer) -> Self::UniqueTimerId
timer. Read moreSource§impl<D: Clone + Into<DeviceId<Self>>> TransmitQueueBindingsContext<D> for FakeBindingsCtx
impl<D: Clone + Into<DeviceId<Self>>> TransmitQueueBindingsContext<D> for FakeBindingsCtx
Source§fn wake_tx_task(&mut self, device: &D)
fn wake_tx_task(&mut self, device: &D)
Source§impl TxMetadataBindingsTypes for FakeBindingsCtx
impl TxMetadataBindingsTypes for FakeBindingsCtx
Source§type TxMetadata = CoreTxMetadata<FakeBindingsCtx>
type TxMetadata = CoreTxMetadata<FakeBindingsCtx>
Source§impl UdpBindingsTypes for FakeBindingsCtx
impl UdpBindingsTypes for FakeBindingsCtx
Source§type ExternalData<I: Ip> = ()
type ExternalData<I: Ip> = ()
Source§type SocketWritableListener = FakeSocketWritableListener
type SocketWritableListener = FakeSocketWritableListener
Source§impl<I: IpExt> UdpReceiveBindingsContext<I, DeviceId<FakeBindingsCtx>> for FakeBindingsCtx
impl<I: IpExt> UdpReceiveBindingsContext<I, DeviceId<FakeBindingsCtx>> for FakeBindingsCtx
Source§fn receive_udp(
&mut self,
id: &UdpSocketId<I, WeakDeviceId<Self>, FakeBindingsCtx>,
_device_id: &DeviceId<Self>,
_meta: UdpPacketMeta<I>,
body: &[u8],
) -> Result<(), ReceiveUdpError>
fn receive_udp( &mut self, id: &UdpSocketId<I, WeakDeviceId<Self>, FakeBindingsCtx>, _device_id: &DeviceId<Self>, _meta: UdpPacketMeta<I>, body: &[u8], ) -> Result<(), ReceiveUdpError>
Source§impl WithFakeFrameContext<DispatchedFrame> for FakeBindingsCtx
impl WithFakeFrameContext<DispatchedFrame> for FakeBindingsCtx
Source§fn with_fake_frame_ctx_mut<O, F: FnOnce(&mut FakeFrameCtx<DispatchedFrame>) -> O>(
&mut self,
f: F,
) -> O
fn with_fake_frame_ctx_mut<O, F: FnOnce(&mut FakeFrameCtx<DispatchedFrame>) -> O>( &mut self, f: F, ) -> O
FakeFrameCtx.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.impl AlwaysDefaultsSettingsContext for FakeBindingsCtx
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<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
impl<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<Id, Ctx> FakeTimerCtxExt<Id> for Ctx
impl<Id, Ctx> FakeTimerCtxExt<Id> for Ctx
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).
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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