pub struct Queue<T> { /* private fields */ }Expand description
A blocking queue with a finite size. For an asynchronous queue, see AsyncQueueSender and
AsyncQueueReceiver.
The items are owned by the queue and move ownership when sending.
Dropping a Queue does not destroy the underlying FreeRTOS queue.
§Usage in FFIs
The implementation works with raw memory representations. This means
that the type T layout must be understandable by the receiver. This
is usually the case for types that are Send and Sized in Rust.
If communication with “C” is expected, users must ensure the types are
C-compatible. This can be achieved by annotating them with the #[repr(C)]
attribute.
Implementations§
Source§impl<T> Queue<T>
impl<T> Queue<T>
Sourcepub fn new(max_size: UBaseType_t) -> Result<Queue<T>, FreeRtosError>
pub fn new(max_size: UBaseType_t) -> Result<Queue<T>, FreeRtosError>
Creates a new Queue with item type T via dynamic memory allocation.
Sourcepub unsafe fn from_raw_handle(handle: QueueHandle_t) -> Self
pub unsafe fn from_raw_handle(handle: QueueHandle_t) -> Self
Creates a Queue from a raw queue handle.
§Safety
handle must be a valid FreeRTOS regular queue handle (not semaphore or mutex).
The queue item type T must match the handle’s item type.
The queue handle must stay valid until the Queue and all its clones are dropped.
Sourcepub fn raw_handle(&self) -> QueueHandle_t
pub fn raw_handle(&self) -> QueueHandle_t
Returns the raw queue handle, a pointer to the queue.
Sourcepub fn send(&self, item: T, max_wait: Duration) -> Result<(), T>
pub fn send(&self, item: T, max_wait: Duration) -> Result<(), T>
Sends an item to the end of the queue. Waits for the queue to have empty space for it.
Sourcepub fn send_from_isr(
&self,
context: &mut InterruptContext,
item: T,
) -> Result<(), T>
pub fn send_from_isr( &self, context: &mut InterruptContext, item: T, ) -> Result<(), T>
Sends an item to the end of the queue, from an interrupt.
Sourcepub fn receive(&self, max_wait: Duration) -> Result<T, FreeRtosError>
pub fn receive(&self, max_wait: Duration) -> Result<T, FreeRtosError>
Waits for an item to be available on the queue.
Sourcepub fn messages_waiting(&self) -> UBaseType_t
pub fn messages_waiting(&self) -> UBaseType_t
Returns the number of messages waiting in the queue.
Sourcepub fn spaces_available(&self) -> UBaseType_t
pub fn spaces_available(&self) -> UBaseType_t
Returns the number of spaces available in the queue.