Skip to main content

Queue

Struct Queue 

Source
pub struct Queue<T: Copy + Sized> { /* private fields */ }
Expand description

A type-safe message queue for communicating between tasks within an application.

The type T must be Copy and Sized to be sent over the queue, as the underlying OSAL API works with raw byte copies.

Implementations§

Source§

impl<T: Copy + Sized> Queue<T>

Source

pub fn new(name: &str, depth: usize) -> Result<Self>

Creates a new message queue.

§Arguments
  • name: A unique string to identify the queue.
  • depth: The maximum number of messages the queue can hold.
Source

pub fn put(&self, message: &T) -> Result<()>

Puts a message onto the queue.

This operation is non-blocking. If the queue is full, an error is returned.

§Arguments
  • message: A reference to the message data to send.
Source

pub fn get(&self, timeout_ms: i32) -> Result<T>

Retrieves a message from the queue.

This operation can block until a message is available, depending on the timeout.

§Arguments
  • timeout_ms: Timeout in milliseconds. Can be a positive value, ffi::OS_CHECK (0) for a non-blocking poll, or ffi::OS_PEND (-1) to block indefinitely.
Source

pub fn id(&self) -> OsalId

Returns the underlying OSAL ID of the queue.

Source

pub fn get_id_by_name(name: &str) -> Result<OsalId>

Finds an existing queue ID by its name.

Source

pub fn get_info(&self) -> Result<QueueProp>

Retrieves information about this queue.

Trait Implementations§

Source§

impl<T: Debug + Copy + Sized> Debug for Queue<T>

Source§

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

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

impl<T: Copy + Sized> Drop for Queue<T>

Source§

fn drop(&mut self)

Deletes the OSAL queue when the Queue object goes out of scope.

Auto Trait Implementations§

§

impl<T> Freeze for Queue<T>

§

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

§

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

§

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

§

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

§

impl<T> UnsafeUnpin for Queue<T>

§

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