quartiq / minimq

Minimal no_std MQTT v5.0 client implementation
MIT License
146 stars 16 forks source link

Consider simplifying message construction #110

Closed ryan-summers closed 2 years ago

ryan-summers commented 2 years ago

Consider simpler ways of constructing Pub messages for the user. It may make sense to allow the user to build a message locally that they provide to the publish() and reply() APIs directly, such as

// Construct a fresh message for publication.
let message = Publish(payload).topic("data/topic").qos(QoS::ExactlyOnce).properties(properties).finish().unwrap();

// Build a reply to a received packet.
let message = Publish(payload).reply(received_properties).finish().unwrap();
mqtt.client.publish(message);