#[cfg(feature = "unstable")]
use heapless::{spsc::Queue, ArrayLength, Vec};
#[cfg(feature = "unstable")]
#[derive(Eq, PartialEq, Debug)]
pub(crate) enum PingPongMode {
Idle,
AActive,
BActive,
}
pub trait Receiver: Default + crate::private::Sealed {}
#[cfg(feature = "unstable")]
pub struct RealReceiver<T, BUFSZ, MSGCT>
where
BUFSZ: ArrayLength<u8>,
MSGCT: ArrayLength<T>,
{
pub(crate) inc_q: Vec<u8, BUFSZ>,
pub(crate) msg_q: Queue<T, MSGCT>,
pub(crate) ppm: PingPongMode,
}
pub struct NullReceiver;
impl Receiver for NullReceiver {}
#[cfg(feature = "unstable")]
impl<T, BUFSZ, MSGCT> Receiver for RealReceiver<T, BUFSZ, MSGCT>
where
BUFSZ: ArrayLength<u8>,
MSGCT: ArrayLength<T>,
{
}
#[cfg(feature = "unstable")]
impl<T, BUFSZ, MSGCT> Default for RealReceiver<T, BUFSZ, MSGCT>
where
BUFSZ: ArrayLength<u8>,
MSGCT: ArrayLength<T>,
{
fn default() -> Self {
Self {
inc_q: Vec::new(),
msg_q: Queue::new(),
ppm: PingPongMode::Idle,
}
}
}
impl Default for NullReceiver {
fn default() -> Self {
NullReceiver
}
}