Skip to main content

UartIo

Trait UartIo 

Source
pub trait UartIo {
    type Error;

    // Required methods
    fn read(&mut self, buf: &mut [u8]) -> UartIoResult<usize, Self::Error>;
    fn write_all(&mut self, bytes: &[u8]) -> UartIoResult<(), Self::Error>;
}
Expand description

Minimal UART byte-stream trait for MCU/no-std backends.

Implement this trait for a board UART, DMA ring, RTOS queue, or test double.

Required Associated Types§

Source

type Error

Transport-specific error type.

Required Methods§

Source

fn read(&mut self, buf: &mut [u8]) -> UartIoResult<usize, Self::Error>

Reads currently available bytes into buf.

Return Ok(0) for EOF-like idle streams, or Err(WouldBlock) when no bytes are available right now.

Source

fn write_all(&mut self, bytes: &[u8]) -> UartIoResult<(), Self::Error>

Writes all bytes to the UART transport.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§