Rust

transport

Module

Byte streams to a NATS server: plain TCP, TLS, and WebSockets.

The Transport trait is the extension point: a crate::ConnectionOptions::transport_factory can hand the connection any implementation (an in-memory double in tests, a proxy, a custom socket).

Contents

3 submodules, and what the module defines itself.

use utopia_nats::transport::TlsOptions;
Rust
pub struct TlsOptions

How a TLS stream verifies the server and presents itself.

Also implements Default.
use utopia_nats::transport::Transport;
Rust
pub trait Transport: Send

A connection-oriented byte stream to one server.

transport::tcp

Own page

Plain TCP, upgradable to TLS in place.

use utopia_nats::transport::tcp::TcpTransport;
Rust
pub struct TcpTransport

A TCP stream with Nagle's algorithm off, which Transport::upgrade_tls turns into TLS when the server asks for it (tls_required) after its plaintext INFO.

transport::tls

Own page

TLS from the first byte (tls://, the server's handshake_first).

use utopia_nats::transport::tls::TlsTransport;
Rust
pub struct TlsTransport

A TLS stream negotiated at connect, before the server's INFO.

transport::websocket

Own page

NATS over WebSockets (ws://, wss://).

use utopia_nats::transport::websocket::WebSocketTransport;
Rust
pub struct WebSocketTransport

The NATS protocol inside binary WebSocket frames (RFC 6455). Frames the client sends are masked; reads serve the unframed byte stream, answering pings and failing on a close frame.