ariel_os::reexports::embassy_net

Struct Stack

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

Network stack handle

Use this to create sockets. It’s Copy, so you can pass it by value instead of by reference.

Implementations§

§

impl<'d> Stack<'d>

pub fn hardware_address(&self) -> HardwareAddress

Get the hardware address of the network interface.

Check whether the link is up.

pub fn is_config_up(&self) -> bool

Check whether the network stack has a valid IP configuration. This is true if the network stack has a static IP configuration or if DHCP has completed

Wait for the network device to obtain a link signal.

Wait for the network device to lose link signal.

pub async fn wait_config_up(&self)

Wait for the network stack to obtain a valid IP configuration.

§Notes:
  • Ensure Runner::run has been started before using this function.

  • This function may never return (e.g. if no configuration is obtained through DHCP). The caller is supposed to handle a timeout for this case.

§Example
let config = embassy_net::Config::dhcpv4(Default::default());
// Init network stack
// NOTE: DHCP and DNS need one socket slot if enabled. This is why we're
// provisioning space for 3 sockets here: one for DHCP, one for DNS, and one for your code (e.g. TCP).
// If you use more sockets you must increase this. If you don't enable DHCP or DNS you can decrease it.
static RESOURCES: StaticCell<embassy_net::StackResources<3>> = StaticCell::new();
let (stack, runner) = embassy_net::new(
   driver,
   config,
   RESOURCES.init(embassy_net::StackResources::new()),
   seed
);
// Launch network task that runs `runner.run().await`
spawner.spawn(net_task(runner)).unwrap();
// Wait for DHCP config
stack.wait_config_up().await;
// use the network stack
// ...

pub async fn wait_config_down(&self)

Wait for the network stack to lose a valid IP configuration.

pub fn config_v4(&self) -> Option<StaticConfigV4>

Available on crate feature proto-ipv4 only.

Get the current IPv4 configuration.

If using DHCP, this will be None if DHCP hasn’t been able to acquire an IP address, or Some if it has.

pub fn config_v6(&self) -> Option<StaticConfigV6>

Available on crate feature proto-ipv6 only.

Get the current IPv6 configuration.

pub fn set_config_v4(&self, config: ConfigV4)

Available on crate feature proto-ipv4 only.

Set the IPv4 configuration.

pub fn set_config_v6(&self, config: ConfigV6)

Available on crate feature proto-ipv6 only.

Set the IPv6 configuration.

pub async fn dns_query( &self, name: &str, qtype: Type, ) -> Result<Vec<Address, embassy_net::::{impl#3}::dns_query::{opaque#0}::{constant#0}>, Error>

Available on crate feature dns only.

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

Trait Implementations§

§

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

§

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

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'d> !UnwindSafe 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V