1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! Type definitions for the queues used in this crate.

use heapless::spsc::{Consumer, Producer, Queue};
use heapless::Vec;

pub use crate::error::Error;
pub use crate::Command;

// Queue item types
pub type ComItem = Command;
pub type ResItem<BufLen> = Result<Vec<u8, BufLen>, Error>;
pub type UrcItem<BufLen> = Vec<u8, BufLen>;

// Note: We could create a simple macro to define producer, consumer and queue,
// but that would probably be harder to read than just the plain definitions.

// Consumers
pub type ComConsumer<ComCapacity> = Consumer<'static, ComItem, ComCapacity, u8>;
pub type ResConsumer<BufLen, ResCapacity> = Consumer<'static, ResItem<BufLen>, ResCapacity, u8>;
pub type UrcConsumer<BufLen, UrcCapacity> = Consumer<'static, UrcItem<BufLen>, UrcCapacity, u8>;

// Producers
pub type ComProducer<ComCapacity> = Producer<'static, ComItem, ComCapacity, u8>;
pub type ResProducer<BufLen, ResCapacity> = Producer<'static, ResItem<BufLen>, ResCapacity, u8>;
pub type UrcProducer<BufLen, UrcCapacity> = Producer<'static, UrcItem<BufLen>, UrcCapacity, u8>;

// Queues
pub type ComQueue<ComCapacity> = Queue<ComItem, ComCapacity, u8>;
pub type ResQueue<BufLen, ResCapacity> = Queue<ResItem<BufLen>, ResCapacity, u8>;
pub type UrcQueue<BufLen, UrcCapacity> = Queue<UrcItem<BufLen>, UrcCapacity, u8>;