pub struct FakeCtxBuilder { /* private fields */ }Expand description
A builder for FakeCtxs.
A FakeCtxBuilder is capable of storing the configuration of a network
stack including forwarding table entries, devices and their assigned
addresses and configurations, ARP table entries, etc. It can be built using
build, producing a FakeCtx with all of the appropriate state configured.
Implementations§
Source§impl FakeCtxBuilder
impl FakeCtxBuilder
Sourcepub fn with_addrs<A: IpAddress>(addrs: TestAddrs<A>) -> FakeCtxBuilder
pub fn with_addrs<A: IpAddress>(addrs: TestAddrs<A>) -> FakeCtxBuilder
Construct a FakeCtxBuilder from a TestAddrs.
Sourcepub fn add_device(&mut self, mac: UnicastAddr<Mac>) -> usize
pub fn add_device(&mut self, mac: UnicastAddr<Mac>) -> usize
Add a device.
add_device returns a key which can be used to refer to the device in
future calls to add_arp_table_entry and add_device_route.
Sourcepub fn add_device_with_config(
&mut self,
mac: UnicastAddr<Mac>,
ipv4_config: Ipv4DeviceConfigurationUpdate,
ipv6_config: Ipv6DeviceConfigurationUpdate,
) -> usize
pub fn add_device_with_config( &mut self, mac: UnicastAddr<Mac>, ipv4_config: Ipv4DeviceConfigurationUpdate, ipv6_config: Ipv6DeviceConfigurationUpdate, ) -> usize
Add a device with an IPv4 and IPv6 configuration.
add_device_with_config is like add_device, except that it takes an
IPv4 and IPv6 configuration to apply to the device when it is enabled.
Sourcepub fn add_device_with_ip<A: IpAddress>(
&mut self,
mac: UnicastAddr<Mac>,
ip: A,
subnet: Subnet<A>,
) -> usize
pub fn add_device_with_ip<A: IpAddress>( &mut self, mac: UnicastAddr<Mac>, ip: A, subnet: Subnet<A>, ) -> usize
Add a device with an associated IP address.
add_device_with_ip is like add_device, except that it takes an
associated IP address and subnet to assign to the device.
Sourcepub fn add_device_with_ip_and_config<A: IpAddress>(
&mut self,
mac: UnicastAddr<Mac>,
ip: A,
subnet: Subnet<A>,
ipv4_config: Ipv4DeviceConfigurationUpdate,
ipv6_config: Ipv6DeviceConfigurationUpdate,
) -> usize
pub fn add_device_with_ip_and_config<A: IpAddress>( &mut self, mac: UnicastAddr<Mac>, ip: A, subnet: Subnet<A>, ipv4_config: Ipv4DeviceConfigurationUpdate, ipv6_config: Ipv6DeviceConfigurationUpdate, ) -> usize
Add a device with an associated IP address and a particular IPv4 and IPv6 configuration.
add_device_with_ip_and_config is like add_device, except that it
takes an associated IP address and subnet to assign to the device, as
well as IPv4 and IPv6 configurations to apply to the device when it is
enabled.
Sourcepub fn add_arp_table_entry(
&mut self,
device: usize,
ip: SpecifiedAddr<Ipv4Addr>,
mac: UnicastAddr<Mac>,
)
pub fn add_arp_table_entry( &mut self, device: usize, ip: SpecifiedAddr<Ipv4Addr>, mac: UnicastAddr<Mac>, )
Add an ARP table entry for a device’s ARP table.
Sourcepub fn add_ndp_table_entry(
&mut self,
device: usize,
ip: UnicastAddr<Ipv6Addr>,
mac: UnicastAddr<Mac>,
)
pub fn add_ndp_table_entry( &mut self, device: usize, ip: UnicastAddr<Ipv6Addr>, mac: UnicastAddr<Mac>, )
Add an NDP table entry for a device’s NDP table.
Sourcepub fn add_arp_or_ndp_table_entry<A: IpAddress>(
&mut self,
device: usize,
ip: SpecifiedAddr<A>,
mac: UnicastAddr<Mac>,
)
pub fn add_arp_or_ndp_table_entry<A: IpAddress>( &mut self, device: usize, ip: SpecifiedAddr<A>, mac: UnicastAddr<Mac>, )
Add either an NDP entry (if IPv6) or ARP entry (if IPv4) to a
FakeCtxBuilder.
Sourcepub fn build(self) -> (FakeCtx, Vec<EthernetDeviceId<FakeBindingsCtx>>)
pub fn build(self) -> (FakeCtx, Vec<EthernetDeviceId<FakeBindingsCtx>>)
Builds a Ctx from the present configuration with a default dispatcher.
Sourcepub fn build_with_modifications<F: FnOnce(&mut StackStateBuilder)>(
self,
f: F,
) -> (FakeCtx, Vec<EthernetDeviceId<FakeBindingsCtx>>)
pub fn build_with_modifications<F: FnOnce(&mut StackStateBuilder)>( self, f: F, ) -> (FakeCtx, Vec<EthernetDeviceId<FakeBindingsCtx>>)
build_with_modifications is equivalent to build, except that after
the StackStateBuilder is initialized, it is passed to f for further
modification before the Ctx is constructed.
Sourcepub fn build_with(
self,
state_builder: StackStateBuilder,
) -> (FakeCtx, Vec<EthernetDeviceId<FakeBindingsCtx>>)
pub fn build_with( self, state_builder: StackStateBuilder, ) -> (FakeCtx, Vec<EthernetDeviceId<FakeBindingsCtx>>)
Build a Ctx from the present configuration with a caller-provided
dispatcher and StackStateBuilder.
Trait Implementations§
Source§impl Clone for FakeCtxBuilder
impl Clone for FakeCtxBuilder
Source§fn clone(&self) -> FakeCtxBuilder
fn clone(&self) -> FakeCtxBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for FakeCtxBuilder
impl Default for FakeCtxBuilder
Source§fn default() -> FakeCtxBuilder
fn default() -> FakeCtxBuilder
Auto Trait Implementations§
impl Freeze for FakeCtxBuilder
impl RefUnwindSafe for FakeCtxBuilder
impl Send for FakeCtxBuilder
impl Sync for FakeCtxBuilder
impl Unpin for FakeCtxBuilder
impl UnwindSafe for FakeCtxBuilder
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<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