{"id":15287706,"url":"https://github.com/00imvj00/mqttrs","last_synced_at":"2025-05-15T17:07:17.437Z","repository":{"id":34227649,"uuid":"168913580","full_name":"00imvj00/mqttrs","owner":"00imvj00","description":"Async Mqtt encoder and decoder for rust.","archived":false,"fork":false,"pushed_at":"2025-02-12T10:18:58.000Z","size":185,"stargazers_count":138,"open_issues_count":8,"forks_count":19,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-07T23:03:59.737Z","etag":null,"topics":["mqtt","mqtt-library","mqtt-protocol","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/00imvj00.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["00imvj00"]}},"created_at":"2019-02-03T05:38:42.000Z","updated_at":"2025-03-21T16:44:04.000Z","dependencies_parsed_at":"2025-01-19T10:00:47.372Z","dependency_job_id":"10baaf1d-d598-47c7-9fae-eb4e327054c6","html_url":"https://github.com/00imvj00/mqttrs","commit_stats":{"total_commits":121,"total_committers":9,"mean_commits":"13.444444444444445","dds":0.5619834710743802,"last_synced_commit":"5bf355b61ec2b4f88ba14f4686c650e125a81bef"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/00imvj00%2Fmqttrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/00imvj00%2Fmqttrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/00imvj00%2Fmqttrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/00imvj00%2Fmqttrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/00imvj00","download_url":"https://codeload.github.com/00imvj00/mqttrs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384987,"owners_count":22062422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mqtt","mqtt-library","mqtt-protocol","rust"],"created_at":"2024-09-30T15:35:27.983Z","updated_at":"2025-05-15T17:07:12.428Z","avatar_url":"https://github.com/00imvj00.png","language":"Rust","funding_links":["https://github.com/sponsors/00imvj00"],"categories":[],"sub_categories":[],"readme":"# Rust Mqtt Encoding \u0026 Decoding  [![Crates.io](https://img.shields.io/crates/l/mqttrs)](LICENSE) [![Docs.rs](https://docs.rs/mqttrs/badge.svg)](https://docs.rs/mqttrs/*/mqttrs/)\n\n`Mqttrs` is a [Rust](https://www.rust-lang.org/) crate (library) to write [MQTT\nprotocol](https://mqtt.org/) clients and servers.\n\nIt is a codec-only library with [very few dependencies](Cargo.toml) and a [straightforward and\ncomposable API](https://docs.rs/mqttrs/*/mqttrs/), usable with rust's standard library or with async\nframeworks like [tokio](https://tokio.rs/). It is strict when decoding (e.g. returns an error when\nencountering reserved values) and encoding (the API makes it impossible to generate an illegal\npacket).\n\n`Mqttrs` currently requires [Rust \u003e= 1.39](https://www.rust-lang.org/learn/get-started) and supports\n[MQTT 3.1.1](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html). Support for [MQTT\n5](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html) is planned for a future version.\n\n\n## Usage\n\nAdd `mqttrs = \"0.4\"` and `bytes = \"1.0\"` to your `Cargo.toml`.\n\n```rust\nuse mqttrs::*;\nuse bytes::BytesMut;\n\n// Allocate write buffer.\nlet mut buf = BytesMut::with_capacity(1024);\n\n// Encode an MQTT Connect packet.\nlet pkt = Packet::Connect(Connect { protocol: Protocol::MQTT311,\n                                    keep_alive: 30,\n                                    client_id: \"doc_client\".into(),\n                                    clean_session: true,\n                                    last_will: None,\n                                    username: None,\n                                    password: None });\nassert!(encode(\u0026pkt, \u0026mut buf).is_ok());\nassert_eq!(\u0026buf[14..], \"doc_client\".as_bytes());\nlet mut encoded = buf.clone();\n\n// Decode one packet. The buffer will advance to the next packet.\nassert_eq!(Ok(Some(pkt)), decode(\u0026mut buf));\n\n// Example decode failures.\nlet mut incomplete = encoded.split_to(10);\nassert_eq!(Ok(None), decode(\u0026mut incomplete));\nlet mut garbage = BytesMut::from(\u0026[0u8,0,0,0] as \u0026[u8]);\nassert_eq!(Err(Error::InvalidHeader), decode(\u0026mut garbage));\n```\n\n## Optional [serde](https://serde.rs/) support.\n\nUse  `mqttrs = { version = \"0.4\", features = [ \"derive\" ] }` in your `Cargo.toml`.\n\nEnabling this features adds `#[derive(Deserialize, Serialize)]` to some `mqttrs` types. This\nsimplifies storing those structs in a database or file, typically to implement session support (qos,\nsubscriptions...).\n\nThis doesn't add mqtt as a serde data format; you still need to use the `mqttrs::{decode,encode}`\nfunctions.\n\n## Optional `#[no_std]` support.\n\nUse `mqttrs = { version = \"0.4\", default-features = false }` in your `Cargo.toml` to remove the\ndefault `std` feature.\n\nDisabling this feature comes with the cost of not implementing the `std::error::Error` trait,\nas well as not supporting `std::io` read and write. This allows usage in embedded devices\nwhere the standard library is not available.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F00imvj00%2Fmqttrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F00imvj00%2Fmqttrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F00imvj00%2Fmqttrs/lists"}