Skip to main content

Stack

Struct Stack 

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

Cheap (Copy) handle to a Stack. Pass to user tasks; clone freely.

Implementations§

Source§

impl<'a> Stack<'a>

Source

pub fn new<TRX, const N_RX: usize>( trx: TRX, address: Address, resources: &'a mut StackResources<N_RX>, timing: MacTiming, ) -> (Stack<'a>, Runner<'a, TRX>)

Splits caller-allocated resources into a Stack handle and a Runner that owns the radio. After this call the resources are pinned in place via the returned references.

Source

pub fn address(&self) -> Address

The local address this Stack was constructed with.

Current snapshot of the radio link state. See module-level docs for the transition rules.

Resolves when the link state is (or becomes) LinkState::Up. Returns immediately if already up.

Only one task may hold this future at a time; running it in two tasks concurrently is undefined (one will be woken on the next transition, the other can stay parked).

Resolves when the link state is (or becomes) LinkState::Down. Returns immediately if already down. Same single-waiter caveat as Stack::wait_link_up.

Source

pub async fn send( &self, dst: Address, flags: Flags, data: &[u8], ) -> Result<(), TxError>

Send data to dst with the given flags. Serialized across all concurrent callers via an internal mutex (the radio is half-duplex, so only one TX flies at a time anyway).

The order under the lock is lock → reset response → enqueue request → await response, in that order. Resetting under the lock is the cancellation-safety invariant: a previously-cancelled caller may have left a stale value in the Signal, and clearing it before posting our own request makes sure we wait for the response to our TX, not the dead one’s. See the module-level docs.

Source

pub async fn recv(&self) -> Packet

Wait for the next packet addressed to this Stack (Unicast match) or to Address::Broadcast. Other unicasts are filtered out by the Runner before they reach the queue.

Trait Implementations§

Source§

impl<'a> Clone for Stack<'a>

Source§

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

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<'a> Copy for Stack<'a>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<'a> Freeze for Stack<'a>

§

impl<'a> Unpin for Stack<'a>

§

impl<'a> UnsafeUnpin for Stack<'a>

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 = 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.