MqttTransport

Trait MqttTransport 

Source
pub trait MqttTransport {
    type Error: Debug;

    // Required methods
    async fn send(&mut self, buf: &[u8]) -> Result<(), Self::Error>;
    async fn recv(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>;
}
Expand description

A trait representing a transport for MQTT packets.

This trait abstracts over any reliable, ordered, stream-based communication channel.

Required Associated Types§

Source

type Error: Debug

The error type returned by the transport.

Required Methods§

Source

async fn send(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Sends a buffer of data over the transport.

Source

async fn recv(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Receives data from the transport into a buffer.

Returns the number of bytes read.

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§