Queue

Struct Queue 

Source
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>
where T: Send + Sized + 'static,

Source

pub fn new(max_size: UBaseType_t) -> Result<Queue<T>, FreeRtosError>

Creates a new Queue with item type T via dynamic memory allocation.

Source

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.

Source

pub fn raw_handle(&self) -> QueueHandle_t

Returns the raw queue handle, a pointer to the queue.

Source

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.

Source

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.

Source

pub fn receive(&self, max_wait: Duration) -> Result<T, FreeRtosError>

Waits for an item to be available on the queue.

Source

pub fn messages_waiting(&self) -> UBaseType_t

Returns the number of messages waiting in the queue.

Source

pub fn spaces_available(&self) -> UBaseType_t

Returns the number of spaces available in the queue.

Trait Implementations§

Source§

impl<T> Clone for Queue<T>

Source§

fn clone(&self) -> Self

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

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Queue<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Send for Queue<T>

Source§

impl<T> Sync for Queue<T>

Source§

impl<T> Unpin for Queue<T>

Auto Trait Implementations§

§

impl<T> Freeze for Queue<T>

§

impl<T> RefUnwindSafe for Queue<T>
where T: RefUnwindSafe,

§

impl<T> UnwindSafe for Queue<T>
where T: UnwindSafe,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.