Skip to main content

Crate tjiftjaf

Crate tjiftjaf 

Source
Expand description

tjiftjaf is a Rust library implementing MQTT 3.1.1.

§Features

MQTT Client

The crate provides a blocking Client and an asynchronous Client.

The latter does not require a specific runtime executor.

Take a look at the examples:

§Do not use this crate

I created this project to learn more about MQTT, fuzzing, sans-io and zero-copy.

Do not rely on this crate for your own projects. It’s unstable. Consider using rumqttc instead.

§Fuzzer

Portions of the code are verified using fuzzing. Make sure to install cargo fuzz before running the examples.

cargo +nightly fuzz run subscribe

List all fuzz targets using:

cargo +nightly fuzz list

§Benchmarks

The project uses Criterion.rs to benchmark encoding and decoding speed of packets. Run all benchmarks using:

$ cargo bench

To list all benchmarks run:

$ cargo bench -- --list

You can plot a flamegraph of a benchmark. First build the benchmark into a binary.

$ cargo bench --no-run
  ...
  Executable benches/decode-encode.rs (target/release/deps/decode_encode-9f10de3c0a084302)

Then, invoke the binary with flamegraph. This example runs only 1 benchmark that matches the string ‘Publish’:

$ flamegraph -- target/release/deps/decode_encode-9f10de3c0a084302 --bench Publish
...
Benchmarking decode/encode Publish: Complete (Analysis Disabled)
...
[ perf record: Captured and wrote 1264.806 MB perf.data (79730 samples) ]
writing flamegraph to "flamegraph.svg"

§License

This project is licensed under the Mozilla Public License.

Modules§

aio
An asynchronous MQTT Client.
blocking
A blocking MQTT Client.
decode
packet

Structs§

ClientDisconnected
An error indicating that the client terminated the connection with the server.
ConnAck
Connack
Connect
Connect is the first packet a client sends, after a connection has been established.
ConnectionError
Type indicating that the connection between a handle and the Client is broken. It’s likely that the connection to the MQTT server broke.
Disconnect
The Disconnect Packet is sent from a Client to the Server.
MqttBinding
PingReq
The PINGREQ Packet is sent from a Client to the Server. It can be used to:
PingResp
A PINGRESP Packet is sent by the Server to the Client in response to a PINGREQ Packet. It indicates that the Server is alive.
PubAck
A PubAck packet is the response to a crate::Publish packet with crate::QoS::AtLeastOnceDelivery.
PubComp
PubComp is the response to a crate::PubRel packet with crate::QoS::ExactlyOnceDelivery.
PubRec
A PubRec packet is the response to a crate::Publish packet with crate::QoS::ExactlyOnceDelivery.
PubRel
A PubRel packet is the response to a crate::PubRec.
Publish
Publish is used by both clients and servers to emit a message for a specific topic.
SubAck
SubAck is emitted by a broker to confirm a crate::Subscribe request.
Subscribe
Subscribe allows a client to express interest in one or more topics.
UnsubAck
A UnsubAck packet is the response to a crate::Unsubscribe.
Unsubscribe
Unsubscribe allows a client unsubscribe from one or more topics.

Enums§

DecodingError
Packet
A model for each MQTT packet.
PacketType
Every packet type of MQTT 3.1.1.
ProtocolLevel
The revision of the MQTT protocol.
QoS
The delivery guarantee for packets Subscribe and Publish.

Traits§

Frame

Functions§

connect
packet_identifier
publish
Construct a Publish with the given topic and payload.
subscribe
Construct a Subscribe with the given topic and QoS::AtMostOnceDelivery.
unsubscribe
Construct a Unsubscribe with the given topic.