1 unstable release

0.0.1 Dec 31, 2023

#143 in #mqtt

BSD-2-Clause OR MIT

59KB
1K SLoC

License BSD-2-Clause License MIT AppVeyor CI

mqtt-tiny

Welcome to mqtt-tiny 🎉

mqtt-tiny is a tiny MQTT 3.1.1 codec implementation. It is limited to packet en-/decoding, and does not handle state or transport-level stuff.

Example

use mqtt_tiny::packets::connect::MqttConnect;

// Create a simple connect packet
const CLIENT_ID: &str = "mqtttinyreadmeexample";
let connect = MqttConnect::new(
    30,        //keep_alive_secs: u16,
    true,      //clean_session: bool,
    CLIENT_ID, //client_id: impl ToString,
);

// Serialize the connect packet
let connect_bytes = connect.write(Vec::new()).unwrap();
assert_eq!(connect_bytes.len(), 35);

Running provided examples

To run the provided example, just set the MQTT_ADDRESS, MQTT_USERNAME and MQTT_PASSWORD environment variables respectively to connect to your server.

No runtime deps