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>
impl<'a> Stack<'a>
Sourcepub fn new<TRX, const N_RX: usize>(
trx: TRX,
address: Address,
resources: &'a mut StackResources<N_RX>,
timing: MacTiming,
) -> (Stack<'a>, Runner<'a, TRX>)
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>)
Sourcepub fn link_state(&self) -> LinkState
pub fn link_state(&self) -> LinkState
Current snapshot of the radio link state. See module-level docs for the transition rules.
Sourcepub fn is_link_up(&self) -> bool
pub fn is_link_up(&self) -> bool
true iff Stack::link_state is LinkState::Up.
Sourcepub async fn wait_link_up(&self)
pub async fn wait_link_up(&self)
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).
Sourcepub async fn wait_link_down(&self)
pub async fn wait_link_down(&self)
Resolves when the link state is (or becomes) LinkState::Down.
Returns immediately if already down. Same single-waiter caveat as
Stack::wait_link_up.
Sourcepub async fn send(
&self,
dst: Address,
flags: Flags,
data: &[u8],
) -> Result<(), TxError>
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.