Skip to main content

Transport

Trait Transport 

pub trait Transport {
    type Io: AsyncRead + AsyncWrite + Unpin + Send + 'static;

    // Required method
    fn connect(&self) -> impl Future<Output = Result<Self::Io>> + Send;
}
Available on crate feature tokio only.
Expand description

A transport that can establish a byte-stream connection to an MQTT broker.

Implement this trait for each transport type (TCP, TLS, WebSocket, etc.). The produced Io stream must support full-duplex byte I/O.

Required Associated Types§

type Io: AsyncRead + AsyncWrite + Unpin + Send + 'static

The I/O stream type produced by this transport.

Required Methods§

fn connect(&self) -> impl Future<Output = Result<Self::Io>> + Send

Establish a connection to the broker.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

§

impl Transport for TcpTransport

§

type Io = TcpStream

§

impl Transport for TlsTransport

Available on crate feature tls only.
§

type Io = TlsStream<TcpStream>