// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie // SPDX-License-Identifier: MIT //! Moving MQTT along a stream. //! //! The `mqtt` module knows the protocol and nothing else: it takes bytes in and //! gives bytes out. This module is what carries those bytes, and it is separate //! so that a program with an event loop of its own -- which is most of the //! reason to want a sans-I/O core -- never compiles a line of it and never sees //! `std.Io.Reader` in its dependency graph. //! //! `Client` is a connection plus a reader and a writer the caller opened. It //! makes no attempt to own the transport: if the socket breaks, the error comes //! back and what to do about it is the caller's business. //! //! `Reconnecting` is the answer for a caller whose business that is not. It //! owns a `Transport`, opens one when it needs one, reopens it with backoff //! when it breaks, resumes the MQTT session across the gap, and re-subscribes //! when the broker says the session did not survive. `Transport` is a two-entry //! vtable, and all three of the implementations here -- `Tcp`, `Tls` and //! `WebSocket` -- are behind it, so which one a program uses is a line where //! the transport is built and nothing else. //! //! Extended authentication (section 4.12) is here too, and for the same //! reason: it is a SASL exchange carried in MQTT packets, so what belongs to //! MQTT is the carrying and what belongs to SASL is the mechanism. `Client` //! takes a `sasl.Client` and drives it; `Reconnecting` takes a way to build //! one, because an exchange runs once and it opens many connections -- which //! is also what lets it re-authenticate an established connection without //! interrupting anything. const std = @import("std"); /// The TLS library underneath `Transport.Tls`, re-exported. /// /// Consumers need it to build the things `Transport.Tls.Options` takes -- a /// `tls.config.CertKeyPair` for mutual TLS, or a `Certificate.Bundle` to /// share across connections -- and making them add a dependency of their own, /// pinned to the same commit as this one, would be a poor trade for a type. pub const tls = @import("tls"); /// The WebSocket library underneath `Transport.WebSocket`, re-exported. /// /// Consumers need it for `Transport.WebSocket.Options.headers`, whose element /// type lives there, and for the close codes and message kinds if they look /// below the transport at all. pub const websocket = @import("websocket"); /// The SASL interface underneath `Client.Authentication`, re-exported. /// /// Consumers need it to build a mechanism -- `sasl.Plain`, `sasl.External`, or /// SCRAM through zig-scram's `scram-sasl` adapter -- and it is the interface /// rather than a mechanism on purpose: MQTT section 4.12 says a method name /// and some opaque bytes, and which mechanism those bytes belong to is the /// caller's business and not this library's. pub const sasl = @import("sasl"); pub const Client = @import("Client.zig"); pub const Reconnecting = @import("Reconnecting.zig"); pub const Transport = @import("Transport.zig"); test { _ = tls; _ = websocket; _ = sasl; _ = Client; _ = Reconnecting; _ = Transport; }