Struct smoltcp::iface::InterfaceBuilder
source · [−]pub struct InterfaceBuilder<'a, DeviceT: for<'d> Device<'d>> { /* private fields */ }Expand description
A builder structure used for creating a network interface.
Implementations
sourceimpl<'a, DeviceT> InterfaceBuilder<'a, DeviceT> where
DeviceT: for<'d> Device<'d>,
impl<'a, DeviceT> InterfaceBuilder<'a, DeviceT> where
DeviceT: for<'d> Device<'d>,
sourcepub fn new<SocketsT>(device: DeviceT, sockets: SocketsT) -> Self where
SocketsT: Into<ManagedSlice<'a, SocketStorage<'a>>>,
pub fn new<SocketsT>(device: DeviceT, sockets: SocketsT) -> Self where
SocketsT: Into<ManagedSlice<'a, SocketStorage<'a>>>,
Create a builder used for creating a network interface using the given device and address.
Examples
use smoltcp::iface::{InterfaceBuilder, NeighborCache};
use smoltcp::wire::{EthernetAddress, IpCidr, IpAddress};
let device = // ...
let hw_addr = // ...
let neighbor_cache = // ...
let ip_addrs = // ...
let iface = InterfaceBuilder::new(device, vec![])
.hardware_addr(hw_addr.into())
.neighbor_cache(neighbor_cache)
.ip_addrs(ip_addrs)
.finalize();sourcepub fn random_seed(self, random_seed: u64) -> Self
pub fn random_seed(self, random_seed: u64) -> Self
Set the random seed for this interface.
It is strongly recommended that the random seed is different on each boot, to avoid problems with TCP port/sequence collisions.
The seed doesn’t have to be cryptographically secure.
sourcepub fn hardware_addr(self, addr: HardwareAddress) -> Self
pub fn hardware_addr(self, addr: HardwareAddress) -> Self
Set the Hardware address the interface will use. See also hardware_addr.
Panics
This function panics if the address is not unicast.
sourcepub fn ip_addrs<T>(self, ip_addrs: T) -> Self where
T: Into<ManagedSlice<'a, IpCidr>>,
pub fn ip_addrs<T>(self, ip_addrs: T) -> Self where
T: Into<ManagedSlice<'a, IpCidr>>,
sourcepub fn any_ip(self, enabled: bool) -> Self
pub fn any_ip(self, enabled: bool) -> Self
Enable or disable the AnyIP capability, allowing packets to be received locally on IPv4 addresses other than the interface’s configured ip_addrs. When AnyIP is enabled and a route prefix in routes specifies one of the interface’s ip_addrs as its gateway, the interface will accept packets addressed to that prefix.
IPv6
This option is not available or required for IPv6 as packets sent to the interface are not filtered by IPv6 address.
sourcepub fn routes<T>(self, routes: T) -> InterfaceBuilder<'a, DeviceT> where
T: Into<Routes<'a>>,
pub fn routes<T>(self, routes: T) -> InterfaceBuilder<'a, DeviceT> where
T: Into<Routes<'a>>,
Set the IP routes the interface will use. See also routes.
sourcepub fn ipv4_multicast_groups<T>(self, ipv4_multicast_groups: T) -> Self where
T: Into<ManagedMap<'a, Ipv4Address, ()>>,
pub fn ipv4_multicast_groups<T>(self, ipv4_multicast_groups: T) -> Self where
T: Into<ManagedMap<'a, Ipv4Address, ()>>,
Provide storage for multicast groups.
Join multicast groups by calling join_multicast_group() on an Interface.
Using join_multicast_group() will send initial membership reports.
A previously destroyed interface can be recreated by reusing the multicast group
storage, i.e. providing a non-empty storage to ipv4_multicast_groups().
Note that this way initial membership reports are not sent.
sourcepub fn neighbor_cache(self, neighbor_cache: NeighborCache<'a>) -> Self
pub fn neighbor_cache(self, neighbor_cache: NeighborCache<'a>) -> Self
Set the Neighbor Cache the interface will use.
Auto Trait Implementations
impl<'a, DeviceT> RefUnwindSafe for InterfaceBuilder<'a, DeviceT> where
DeviceT: RefUnwindSafe,
impl<'a, DeviceT> Send for InterfaceBuilder<'a, DeviceT> where
DeviceT: Send,
impl<'a, DeviceT> Sync for InterfaceBuilder<'a, DeviceT> where
DeviceT: Sync,
impl<'a, DeviceT> Unpin for InterfaceBuilder<'a, DeviceT> where
DeviceT: Unpin,
impl<'a, DeviceT> !UnwindSafe for InterfaceBuilder<'a, DeviceT>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more