Crates.io | mqtt-tiny |
lib.rs | mqtt-tiny |
version | 0.0.1 |
source | src |
created_at | 2023-12-31 17:05:20.444188 |
updated_at | 2023-12-31 17:05:20.444188 |
description | A tiny MQTT v3.1.1 codec implementation |
homepage | |
repository | https://github.com/KizzyCode/mqtt-tiny-rust |
max_upload_size | |
id | 1084916 |
size | 87,121 |
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.
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);
To run the provided example, just set the MQTT_ADDRESS
, MQTT_USERNAME
and MQTT_PASSWORD
environment variables
respectively to connect to your server.