Struct heapless::spsc::Consumer[][src]

pub struct Consumer<'a, T, N, U = usize, C = MultiCore> where
    N: ArrayLength<T>,
    U: Uxx,
    C: XCore, 
{ /* fields omitted */ }
Expand description

A queue “consumer”; it can dequeue items from the queue

Implementations

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

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

Examples

use heapless::spsc::Queue;
use heapless::consts::*;

let mut queue: Queue<u8, U235, _> = Queue::u8();
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());

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 it’s empty

Unsafety

If the queue is empty this is equivalent to calling mem::uninitialized

Returns the maximum number of elements the queue can hold

Returns the number of elements in the queue

Note

This is a conservative estimate. Interrupt during this function might cause that the Consumer actually has more than N items available.

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

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

Examples

use heapless::spsc::Queue;
use heapless::consts::*;

let mut queue: Queue<u8, U235, _> = Queue::u8();
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());

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 it’s empty

Unsafety

If the queue is empty this is equivalent to calling mem::uninitialized

Returns the maximum number of elements the queue can hold

Returns the number of elements in the queue

Note

This is a conservative estimate. Interrupt during this function might cause that the Consumer actually has more than N items available.

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

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

Examples

use heapless::spsc::Queue;
use heapless::consts::*;

let mut queue: Queue<u8, U235, _> = Queue::u8();
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());

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 it’s empty

Unsafety

If the queue is empty this is equivalent to calling mem::uninitialized

Returns the maximum number of elements the queue can hold

Returns the number of elements in the queue

Note

This is a conservative estimate. Interrupt during this function might cause that the Consumer actually has more than N items available.

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

Performs the conversion.

Performs the conversion.

Should always be Self

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.