symqtt 0.1.1

Synchronous MQTT 3.1.1/5.0 client — blocking API, no async runtime
Documentation
//! Enhanced Authentication support for MQTT 5.0 [MQTTv5-4.12]
//!
//! Provides the `AuthHandler` trait for multi-round authentication flows.

use bytes::Bytes;

/// User-implemented handler for MQTT 5.0 enhanced authentication.
///
/// When `ConnectOptions::auth_method` is set, the client engages in an
/// extended authentication flow. The server may send AUTH(Continue) packets
/// requiring additional client data before granting access.
pub trait AuthHandler: Send + Sync + 'static {
    /// Called when the server sends AUTH with reason code 0x18 (Continue Authentication).
    ///
    /// The `server_data` parameter contains the server's authentication data (if any).
    /// Return the next round of client authentication data, or `None` to abort.
    fn on_auth_continue(&self, server_data: Option<&Bytes>) -> Option<Bytes>;

    /// Called when authentication completes successfully (after CONNACK or re-auth)
    fn on_authenticated(&self) {}
}

/// A no-op auth handler that aborts on any challenge.
/// Used when no enhanced authentication is configured.
pub struct NoOpAuthHandler;

impl AuthHandler for NoOpAuthHandler {
    fn on_auth_continue(&self, _server_data: Option<&Bytes>) -> Option<Bytes> {
        None
    }
}