#![no_std]
extern crate alloc;
use alloc::boxed::Box;
pub use rdif_base::io;
pub use rdif_base::io::async_trait;
pub use rdif_base::{DriverGeneric, KError};
pub trait Interface: DriverGeneric {
fn handle_irq(&mut self);
fn take_tx(&mut self) -> Option<Box<dyn io::Write>>;
fn take_rx(&mut self) -> Option<Box<dyn io::Read>>;
}
#[derive(thiserror::Error, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[non_exhaustive]
pub enum SerialError {
#[error("The peripheral receive buffer was overrun.")]
Overrun,
#[error("Received data does not conform to the peripheral configuration.")]
FrameFormat,
#[error("Parity check failed.")]
Parity,
#[error("Serial line is too noisy to read valid data.")]
Noise,
#[error("Device was closed.")]
Closed,
#[error("Unknown error.")]
Other,
}
impl From<SerialError> for io::ErrorKind {
fn from(value: SerialError) -> Self {
match value {
SerialError::Closed => io::ErrorKind::BrokenPipe,
_ => io::ErrorKind::Other(Box::new(value)),
}
}
}