pub struct Consumer<'a, T, const N: usize> { /* private fields */ }
Expand description

A queue “consumer”; it can dequeue items from the queue NOTE the consumer semantically owns the head pointer of the queue

Implementations

Returns the item in the front of the queue, or None if the queue is empty

Returns the item in the front of the queue, without checking if there are elements in the queue

See Queue::dequeue_unchecked for safety

Returns if there are any items to dequeue. When this returns true, at least the first subsequent dequeue will succeed

Returns the number of elements in the queue

Returns the maximum number of elements the queue can hold

Returns the item in the front of the queue without dequeuing, or None if the queue is empty

Examples
use heapless::spsc::Queue;

let mut queue: Queue<u8, 235> = Queue::new();
let (mut producer, mut consumer) = queue.split();
assert_eq!(None, consumer.peek());
producer.enqueue(1);
assert_eq!(Some(&1), consumer.peek());
assert_eq!(Some(1), consumer.dequeue());
assert_eq!(None, consumer.peek());

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.