pub struct TxQueue<const N: usize = 16, const FRAME: usize = MAX_RESEND_FRAME_LEN> { /* private fields */ }Expand description
Fixed-capacity, priority-ordered transmit queue owned by the Mac coordinator.
The TxQueue serializes all outgoing frames — MAC ACKs, forwarded frames, retransmissions,
and application sends — into a single ordered sequence for delivery to the radio one at a
time. Entries are serviced in TxPriority order, with FIFO ordering within each class.
The queue capacity N is a compile-time constant (default DEFAULT_TX).
Attempts to enqueue beyond capacity fail with crate::CapacityError, propagated as
SendError::QueueFull or
MacError::QueueFull. Choose N large enough to absorb
the worst-case burst: a forwarded frame, its MAC ACK, plus any application sends already
queued, plus the retransmit backlog.
Internally the queue is an unsorted heapless::Vec<QueuedTx, N>. The dequeue operation
does a linear scan for the highest-priority, lowest-sequence entry whose not_before_ms
has elapsed, which is O(N) — acceptable for the small N typical in embedded deployments.
Implementations§
Source§impl<const N: usize, const FRAME: usize> TxQueue<N, FRAME>
impl<const N: usize, const FRAME: usize> TxQueue<N, FRAME>
Sourcepub fn enqueue(
&mut self,
priority: TxPriority,
frame: &[u8],
receipt: Option<SendReceipt>,
identity_id: Option<LocalIdentityId>,
) -> Result<u32, CapacityError>
pub fn enqueue( &mut self, priority: TxPriority, frame: &[u8], receipt: Option<SendReceipt>, identity_id: Option<LocalIdentityId>, ) -> Result<u32, CapacityError>
Enqueue a frame and return its internal sequence number.
Sourcepub fn enqueue_with_state(
&mut self,
priority: TxPriority,
frame: &[u8],
receipt: Option<SendReceipt>,
identity_id: Option<LocalIdentityId>,
not_before_ms: u64,
cad_attempts: u8,
forward_deferrals: u8,
) -> Result<u32, CapacityError>
pub fn enqueue_with_state( &mut self, priority: TxPriority, frame: &[u8], receipt: Option<SendReceipt>, identity_id: Option<LocalIdentityId>, not_before_ms: u64, cad_attempts: u8, forward_deferrals: u8, ) -> Result<u32, CapacityError>
Enqueue a frame with explicit timer and CAD state.
Sourcepub fn pop_next(&mut self) -> Option<QueuedTx<FRAME>>
pub fn pop_next(&mut self) -> Option<QueuedTx<FRAME>>
Remove and return the highest-priority queued frame.
Sourcepub fn earliest_not_before_ms(&self) -> Option<u64>
pub fn earliest_not_before_ms(&self) -> Option<u64>
Return the earliest not_before_ms across all entries, if any are deferred.
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize, const FRAME: usize> Freeze for TxQueue<N, FRAME>
impl<const N: usize, const FRAME: usize> RefUnwindSafe for TxQueue<N, FRAME>
impl<const N: usize, const FRAME: usize> Send for TxQueue<N, FRAME>
impl<const N: usize, const FRAME: usize> Sync for TxQueue<N, FRAME>
impl<const N: usize, const FRAME: usize> Unpin for TxQueue<N, FRAME>
impl<const N: usize, const FRAME: usize> UnwindSafe for TxQueue<N, FRAME>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)