use crate::Config;
#[derive(Debug)]
pub struct Uninitialized;
#[derive(Debug)]
pub struct Ready;
#[derive(Debug)]
pub struct Sending {
pub(super) finished: bool,
}
impl Sending {
pub fn mark_finished(&mut self) { self.finished = true; }
pub fn is_finished(&self) -> bool { self.finished }
}
#[derive(Debug)]
pub struct SingleBufferReceiving {
pub(super) finished: bool,
pub(super) config: Config,
}
#[derive(Debug)]
pub struct AutoDoubleBufferReceiving {
pub(super) finished: bool,
pub(super) config: Config,
}
#[derive(Debug)]
pub struct Sleeping {
}
pub trait Awake {}
impl Awake for Uninitialized {}
impl Awake for Ready {}
impl Awake for Sending {}
impl Awake for SingleBufferReceiving {}
impl Awake for AutoDoubleBufferReceiving {}
pub trait Asleep {}
impl Asleep for Sleeping {}
pub trait Receiving: Awake {
const AUTO_RX_REENABLE: bool;
const DOUBLE_BUFFERED: bool;
fn mark_finished(&mut self);
fn is_finished(&self) -> bool;
fn get_rx_config(&self) -> &Config;
}
impl Receiving for SingleBufferReceiving {
const AUTO_RX_REENABLE: bool = false;
const DOUBLE_BUFFERED: bool = false;
fn mark_finished(&mut self) { self.finished = true; }
fn is_finished(&self) -> bool { self.finished }
fn get_rx_config(&self) -> &Config { &self.config }
}
impl Receiving for AutoDoubleBufferReceiving {
const AUTO_RX_REENABLE: bool = true;
const DOUBLE_BUFFERED: bool = true;
fn mark_finished(&mut self) { self.finished = true; }
fn is_finished(&self) -> bool { self.finished }
fn get_rx_config(&self) -> &Config { &self.config }
}