pub struct Queue<T: Copy, const N: usize> { /* private fields */ }Expand description
Type-safe FIFO queue with compile-time capacity.
T must be a plain-old-data type (Copy) because items are transferred
through the C API via raw byte copies. N is the queue capacity.
Implementations§
Source§impl<T: Copy, const N: usize> Queue<T, N>
impl<T: Copy, const N: usize> Queue<T, N>
Sourcepub fn send(&self, item: &T, timeout_ms: u32) -> Result<()>
pub fn send(&self, item: &T, timeout_ms: u32) -> Result<()>
Send an item to the queue, blocking up to timeout_ms if the queue is full.
§Errors
Returns Error::QueueFull or Error::Timeout if the item cannot be
enqueued within timeout_ms.
Sourcepub fn receive(&self, timeout_ms: u32) -> Result<T>
pub fn receive(&self, timeout_ms: u32) -> Result<T>
Receive an item from the queue, blocking up to timeout_ms if the queue is empty.
§Errors
Returns Error::Timeout if no item is available within timeout_ms.
Sourcepub fn send_from_isr(&self, item: &T) -> Result<()>
pub fn send_from_isr(&self, item: &T) -> Result<()>
Send an item from an ISR context (non-blocking, returns immediately if full).
§Errors
Returns Error::QueueFull if the queue has no space.
Sourcepub fn receive_from_isr(&self) -> Result<T>
pub fn receive_from_isr(&self) -> Result<T>
Receive an item from an ISR context (non-blocking, returns immediately if empty).
§Errors
Returns Error::Timeout if the queue is empty.
Trait Implementations§
impl<T: Copy + Send, const N: usize> Send for Queue<T, N>
impl<T: Copy + Send, const N: usize> Sync for Queue<T, N>
Auto Trait Implementations§
impl<T, const N: usize> Freeze for Queue<T, N>
impl<T, const N: usize> RefUnwindSafe for Queue<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Unpin for Queue<T, N>where
T: Unpin,
impl<T, const N: usize> UnwindSafe for Queue<T, N>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more