transport
ModuleByte 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;pub struct TlsOptionsHow a TLS stream verifies the server and presents itself.
Default.use utopia_nats::transport::Transport;pub trait Transport: SendA connection-oriented byte stream to one server.
transport::tcp
Own pagePlain TCP, upgradable to TLS in place.
use utopia_nats::transport::tcp::TcpTransport;pub struct TcpTransportA 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 pageTLS from the first byte (tls://, the server's handshake_first).
use utopia_nats::transport::tls::TlsTransport;pub struct TlsTransportA TLS stream negotiated at connect, before the server's INFO.
transport::websocket
Own pageNATS over WebSockets (ws://, wss://).
use utopia_nats::transport::websocket::WebSocketTransport;pub struct WebSocketTransportThe 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.