embassy-net

Crates

git

Versions

default

Flavors

Skip to main content

Stack

Struct Stack 

Source
pub struct Stack<'d> { /* private fields */ }
Expand description

A network stack.

This is a handle to the stack created by Stack::new. It’s Copy, so you can pass it by value instead of by reference.

Implementations§

Source§

impl<'d> Stack<'d>

Source

pub fn new( storage: &'d mut StackStorage<'d>, random_seed: u64, ) -> (Self, Runner<'d>)

Create a new network stack.

The stack starts out with no interfaces: add them with add_iface.

Source

pub fn add_iface(&self, driver: &'d mut dyn Driver) -> Result<Iface<'d>, Full>

Add an interface to the stack, borrowing the driver.

The driver is borrowed for as long as the stack lives. With a StaticCell that is 'static; with a local, the enclosing scope.

§Example
static ETH: StaticCell<Device> = StaticCell::new();
let eth = stack.add_iface(ETH.init(device)).unwrap();
Source

pub fn iface(&self, handle: IfaceHandle) -> Iface<'d>

Get an interface by its handle.

§Panics

Panics if the handle does not belong to an interface on this stack.

Source

pub fn remove_iface(&self, handle: IfaceHandle)

Remove an interface from the stack.

Its addresses, routes and neighbor cache entries go with it. Sockets bound to one of its addresses are not closed, they just stop receiving.

§Panics

Panics if the handle does not belong to an interface on this stack.

Source

pub fn hostname<R>(&self, f: impl FnOnce(Option<&str>) -> R) -> R

The stack’s hostname, or None if not set.

Source

pub fn set_hostname(&self, hostname: &str)

Set the stack’s hostname.

If set, it is sent to the DHCP server in outgoing DHCP messages, as the host name option.

An empty string clears the hostname.

§Panics

Panics if hostname is longer than 63 bytes.

Source

pub fn neighbor_cache(&self) -> NeighborCache<'d>

The stack’s neighbor cache, shared by all interfaces.

Source

pub fn routes(&self) -> Routes<'d>

The stack’s routing table, shared by all interfaces.

Source

pub fn set_dns_servers(&self, servers: &[IpAddress])

Set the DNS servers to use, on top of the ones learned from DHCPv4.

The runner keeps the DNS client’s server list in step with the DHCPv4 leases of every interface. The servers set here are used in addition to those, and come first.

Source

pub async fn dns_query( &self, name: &str, qtype: DnsQueryType, ) -> Result<Vec<IpAddress, { xarxa::config::DNS_MAX_RESULT_COUNT }>, Error>

Make a query for a given name and return the corresponding IP addresses.

Trait Implementations§

Source§

impl<'d> Clone for Stack<'d>

Source§

fn clone(&self) -> Stack<'d>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'d> Copy for Stack<'d>

Auto Trait Implementations§

§

impl<'d> !RefUnwindSafe for Stack<'d>

§

impl<'d> !Send for Stack<'d>

§

impl<'d> !Sync for Stack<'d>

§

impl<'d> !UnwindSafe for Stack<'d>

§

impl<'d> Freeze for Stack<'d>

§

impl<'d> Unpin for Stack<'d>

§

impl<'d> UnsafeUnpin for Stack<'d>

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.