Struct smoltcp::iface::Interface

source ·
pub struct Interface<'a, DeviceT: for<'d> Device<'d>> { /* private fields */ }
Expand description

A network interface.

The network interface logically owns a number of other data structures; to avoid a dependency on heap allocation, it instead owns a BorrowMut<[T]>, which can be a &mut [T], or Vec<T> if a heap is available.

Implementations§

Add a socket to the interface, and return its handle.

Panics

This function panics if the storage is fixed-size (not a Vec) and is full.

Get a socket from the interface by its handle, as mutable.

Panics

This function may panic if the handle does not belong to this socket set or the socket has the wrong type.

Get a socket by handle, and the socket context.

The context is needed for some socket methods.

Panics

This function may panic if the handle does not belong to this socket set or the socket has the wrong type.

Remove a socket from the set, without changing its state.

Panics

This function may panic if the handle does not belong to this socket set.

Get the HardwareAddress address of the interface.

Panics

This function panics if the medium is not Ethernet or Ieee802154.

Set the HardwareAddress address of the interface.

Panics

This function panics if the address is not unicast, and if the medium is not Ethernet or Ieee802154.

Get a reference to the inner device.

Get a mutable reference to the inner device.

There are no invariants imposed on the device by the interface itself. Furthermore the trait implementations, required for references of all lifetimes, guarantees that the mutable reference can not invalidate the device as such. For some devices, such access may still allow modifications with adverse effects on the usability as a phy device. You should not use them this way.

Get an iterator to the inner sockets.

Get a mutable iterator to the inner sockets.

Add an address to a list of subscribed multicast IP addresses.

Returns Ok(announce_sent) if the address was added successfully, where annouce_sent indicates whether an initial immediate announcement has been sent.

Remove an address from the subscribed multicast IP addresses.

Returns Ok(leave_sent) if the address was removed successfully, where leave_sent indicates whether an immediate leave packet has been sent.

Check whether the interface listens to given destination multicast IP address.

Get the IP addresses of the interface.

Get the first IPv4 address if present.

Update the IP addresses of the interface.

Panics

This function panics if any of the addresses are not unicast.

Check whether the interface has the given IP address assigned.

Get the first IPv4 address of the interface.

Transmit packets queued in the given sockets, and receive packets queued in the device.

This function returns a boolean value indicating whether any packets were processed or emitted, and thus, whether the readiness of any socket might have changed.

Errors

This method will routinely return errors in response to normal network activity as well as certain boundary conditions such as buffer exhaustion. These errors are provided as an aid for troubleshooting, and are meant to be logged and ignored.

As a special case, Err(Error::Unrecognized) is returned in response to packets containing any unsupported protocol, option, or form, which is a very common occurrence and on a production system it should not even be logged.

Return a soft deadline for calling poll the next time. The Instant returned is the time at which you should call poll next. It is harmless (but wastes energy) to call it before the Instant, and potentially harmful (impacting quality of service) to call it after the Instant

Return an advisory wait time for calling poll the next time. The Duration returned is the time left to wait before calling poll next. It is harmless (but wastes energy) to call it before the Duration has passed, and potentially harmful (impacting quality of service) to call it after the Duration has passed.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.