Serial

Trait Serial 

Source
pub trait Serial {
    type ReadError;
    type WriteError;

    // Required methods
    fn read_byte_with_timeout(
        &mut self,
        timeout_ms: u32,
    ) -> Result<u8, SerialError<Self::ReadError, Self::WriteError>>;
    fn write_byte(
        &mut self,
        byte: u8,
    ) -> Result<(), SerialError<Self::ReadError, Self::WriteError>>;
}
Expand description

The trait that a serial device must implement to support the transport protocol built atop of it.

Required Associated Types§

Source

type ReadError

Type of error that can occur while reading.

Source

type WriteError

Type of error that can occur while writing.

Required Methods§

Source

fn read_byte_with_timeout( &mut self, timeout_ms: u32, ) -> Result<u8, SerialError<Self::ReadError, Self::WriteError>>

Read a byte from the serial device with a timeout.

§Parameters
  • timeout_ms: Timeout in milliseconds.
§Returns
  • Ok(u8): The byte read.
  • Err([SerialError]): An error occurred.
Source

fn write_byte( &mut self, byte: u8, ) -> Result<(), SerialError<Self::ReadError, Self::WriteError>>

Write a byte to the serial device.

§Parameters
  • byte: The byte to write.
§Returns
  • Ok(()): The byte was written successfully.
  • Err(SerialError): An error occurred.

Implementors§