traits: add idle trait

This commit is contained in:
xoviat 2021-03-23 21:04:18 -05:00
parent 639059ba33
commit 3c9d5b61bb

View File

@ -10,6 +10,15 @@ pub enum Error {
pub trait Uart {
type ReceiveFuture<'a>: Future<Output = Result<(), Error>>;
type SendFuture<'a>: Future<Output = Result<(), Error>>;
/// Receive into the buffer until the buffer is full
fn receive<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a>;
/// Send the specified buffer, and return when the transmission has completed
fn send<'a>(&'a mut self, buf: &'a [u8]) -> Self::SendFuture<'a>;
}
pub trait IdleUart {
type ReceiveFuture<'a>: Future<Output = Result<usize, Error>>;
/// Receive into the buffer until the buffer is full or the line is idle after some bytes are received
/// Return the number of bytes received
fn receive_until_idle<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a>;
}