Skip to main content

mqtt_client_wasm/
types.rs

1//! Common types and configuration
2
3use mqtt_protocol_core::mqtt;
4
5/// MQTT client configuration
6#[derive(Debug, Clone)]
7pub struct MqttConfig {
8    pub url: String,
9    pub version: mqtt::Version,
10    pub pingreq_send_interval_ms: Option<u64>,
11    pub auto_pub_response: bool,
12    pub auto_ping_response: bool,
13    pub auto_map_topic_alias_send: bool,
14    pub auto_replace_topic_alias_send: bool,
15    pub pingresp_recv_timeout_ms: u64,
16    pub connection_establish_timeout_ms: u64,
17    pub shutdown_timeout_ms: u64,
18}
19
20impl Default for MqttConfig {
21    fn default() -> Self {
22        Self {
23            url: String::new(),
24            version: mqtt::Version::V5_0,
25            pingreq_send_interval_ms: None,
26            auto_pub_response: true,
27            auto_ping_response: true,
28            auto_map_topic_alias_send: false,
29            auto_replace_topic_alias_send: false,
30            pingresp_recv_timeout_ms: 0,
31            connection_establish_timeout_ms: 0,
32            shutdown_timeout_ms: 5000,
33        }
34    }
35}
36
37/// Connection state
38#[derive(Debug, Clone, Copy, PartialEq, Eq)]
39pub enum ConnectionState {
40    /// Not connected
41    Disconnected,
42    /// Connecting in progress
43    Connecting,
44    /// Connected and ready
45    Connected,
46    /// Connection lost, attempting to reconnect
47    Reconnecting,
48    /// Connection closed permanently
49    Closed,
50}
51
52// Note: Message type removed - now using mqtt::packet::Packet directly
53// Connection events are handled internally via state management