TestApi

Struct TestApi 

Source
pub struct TestApi<'a, BT: BindingsTypes>(/* private fields */);
Expand description

An API struct for test utilities.

Implementations§

Source§

impl<'l, BC> TestApi<'l, BC>
where BC: BindingsContext,

Source

pub fn join_ip_multicast<A: IpAddress>( &mut self, device: &DeviceId<BC>, multicast_addr: MulticastAddr<A>, )
where A::Version: IpExt, for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<A::Version, BC>, BC: IpBindingsContext<A::Version>,

Joins the multicast group multicast_addr for device.

Source

pub fn leave_ip_multicast<A: IpAddress>( &mut self, device: &DeviceId<BC>, multicast_addr: MulticastAddr<A>, )
where A::Version: IpExt, for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<A::Version, BC>, BC: IpBindingsContext<A::Version>,

Leaves the multicast group multicast_addr for device.

Source

pub fn is_in_ip_multicast<A: IpAddress>( &mut self, device: &DeviceId<BC>, addr: MulticastAddr<A>, ) -> bool
where A::Version: IpExt, for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<A::Version, BC>, BC: IpBindingsContext<A::Version>,

Returns whether device is in the multicast group addr.

Source

pub fn receive_ip_packet<I: Ip, B: BufferMut>( &mut self, device: &DeviceId<BC>, frame_dst: Option<FrameDestination>, buffer: B, )

Receive an IP packet from a device.

receive_ip_packet injects a packet directly at the IP layer for this context.

Source

pub fn receive_ip_packet_with_marks<I: Ip, B: BufferMut>( &mut self, device: &DeviceId<BC>, frame_dst: Option<FrameDestination>, buffer: B, marks: Marks, )

Receive an IP packet from a device with given marks.

receive_ip_packet_with_marks injects a packet directly at the IP layer for this context with the given marks.

Source

pub fn add_route( &mut self, entry: AddableEntryEither<DeviceId<BC>>, ) -> Result<(), AddRouteError>

Add a route directly to the forwarding table.

Source

pub fn set_rules<I: IpExt>(&mut self, rules: Vec<Rule<I, DeviceId<BC>, BC>>)
where for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>, BC: IpBindingsContext<I>,

Install rules, these rules will replace the rules currently installed.

Source

pub fn resolve_route_with_src_addr<I: IpExt>( &mut self, src_ip: IpDeviceAddr<I::Addr>, dst_ip: Option<RoutableIpAddr<I::Addr>>, ) -> Result<ResolvedRoute<I, DeviceId<BC>>, ResolveRouteError>
where for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>, BC: IpBindingsContext<I>,

Resolves a route with a given source address.

Source

pub fn resolve_route_with_marks<I: IpExt>( &mut self, dst_ip: Option<RoutableIpAddr<I::Addr>>, marks: &Marks, ) -> Result<ResolvedRoute<I, DeviceId<BC>>, ResolveRouteError>
where for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>, BC: IpBindingsContext<I>,

Resolves a route with a given mark.

Source

pub fn del_routes_to_subnet( &mut self, subnet: SubnetEither, ) -> Result<(), NotFoundError>

Delete a route from the forwarding table, returning Err if no route was found to be deleted.

Source

pub fn del_device_routes(&mut self, device: &DeviceId<BC>)

Deletes all routes targeting device.

Source

pub fn clear_routes_and_remove_device<D: Into<DeviceId<BC>>>( &mut self, device: D, )

Removes all of the routes through the device, then removes the device.

Source

pub fn set_ip_device_enabled<I: IpExt>( &mut self, device: &DeviceId<BC>, enabled: bool, ) -> bool
where for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>, BC: IpBindingsContext<I>,

Enables or disables the device for IP version I and returns whether it was enabled before.

Source

pub fn enable_device(&mut self, device: &DeviceId<BC>)

Enables device.

Source

pub fn set_unicast_forwarding_enabled<I: IpExt>( &mut self, device: &DeviceId<BC>, enabled: bool, )
where for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>, BC: IpBindingsContext<I>,

Enables or disables IP packet unicast forwarding on device.

Source

pub fn set_multicast_forwarding_enabled<I: IpExt>( &mut self, device: &DeviceId<BC>, enabled: bool, )
where for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>, BC: IpBindingsContext<I>,

Enables or disables IP packet multicast forwarding on device.

Source

pub fn is_unicast_forwarding_enabled<I: IpExt>( &mut self, device: &DeviceId<BC>, ) -> bool
where for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>, BC: IpBindingsContext<I>,

Returns whether IP packet unicast forwarding is enabled on device.

Source

pub fn add_loopback(&mut self) -> LoopbackDeviceId<BC>

Adds a loopback device with the IPv4/IPv6 loopback addresses assigned.

Source§

impl<'a> TestApi<'a, FakeBindingsCtx>

Source

pub fn handle_queued_rx_packets(&mut self) -> bool

Handles any pending frames and returns true if any frames that were in the RX queue were processed.

Auto Trait Implementations§

§

impl<'a, BT> Freeze for TestApi<'a, BT>

§

impl<'a, BT> RefUnwindSafe for TestApi<'a, BT>

§

impl<'a, BT> Send for TestApi<'a, BT>

§

impl<'a, BT> Sync for TestApi<'a, BT>

§

impl<'a, BT> Unpin for TestApi<'a, BT>

§

impl<'a, BT> !UnwindSafe for TestApi<'a, BT>

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
§

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

Source§

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<(), 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.
Source§

impl<L, T> UnlockedAccess<L> for T

Source§

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

The type of state being accessed.
Source§

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

A guard providing read access to the data.
Source§

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

How to access the state.
§

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

§

fn vzip(self) -> V

Source§

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