mqtt-tiny

Crates.iomqtt-tiny
lib.rsmqtt-tiny
version0.0.1
sourcesrc
created_at2023-12-31 17:05:20.444188
updated_at2023-12-31 17:05:20.444188
descriptionA tiny MQTT v3.1.1 codec implementation
homepage
repositoryhttps://github.com/KizzyCode/mqtt-tiny-rust
max_upload_size
id1084916
size87,121
Keziah Biermann (KizzyCode)

documentation

README

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.

Commit count: 0

cargo fmt