Transport

Trait Transport 

Source
pub trait Transport: Send + Sync {
    // Required methods
    fn write(
        &mut self,
        data: &[u8],
    ) -> impl Future<Output = Result<(), TransportError>> + Send;
    fn read(
        &mut self,
        buf: &mut [u8],
    ) -> impl Future<Output = Result<usize, TransportError>> + Send;
    fn close(
        &mut self,
    ) -> impl Future<Output = Result<(), TransportError>> + Send;

    // Provided method
    fn set_baud_rate(&mut self, _baud: u32) -> Result<(), TransportError> { ... }
}
Expand description

Async transport for communicating with the radio.

Implemented for USB serial (CDC ACM), Bluetooth SPP (Serial Port Profile), and mock (testing).

Required Methods§

Source

fn write( &mut self, data: &[u8], ) -> impl Future<Output = Result<(), TransportError>> + Send

Send raw bytes to the radio.

Source

fn read( &mut self, buf: &mut [u8], ) -> impl Future<Output = Result<usize, TransportError>> + Send

Read available bytes into buffer, return count of bytes read.

Source

fn close(&mut self) -> impl Future<Output = Result<(), TransportError>> + Send

Close the connection.

Provided Methods§

Source

fn set_baud_rate(&mut self, _baud: u32) -> Result<(), TransportError>

Change the transport baud rate.

Used when switching between CAT mode (115200 baud over CDC ACM) and programming mode (9600 baud for the entire session). No-op for transports that do not support baud rate changes (e.g., mock).

§Errors

Returns TransportError::Open if the baud rate cannot be applied.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§