From 2abee1d1bbadd83fbc4b2e63be121f20efc41532 Mon Sep 17 00:00:00 2001 From: Subhobrata Dey Date: Mon, 25 Jan 2021 08:19:45 -0800 Subject: [PATCH] #9 Encoders for MQTT --- cloudevents-sdk-paho-mqtt/Cargo.toml | 2 +- cloudevents-sdk-paho-mqtt/src/lib.rs | 3 +-- cloudevents-sdk-paho-mqtt/src/mqtt_producer_record.rs | 8 +++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cloudevents-sdk-paho-mqtt/Cargo.toml b/cloudevents-sdk-paho-mqtt/Cargo.toml index 160eb58d..f6076876 100644 --- a/cloudevents-sdk-paho-mqtt/Cargo.toml +++ b/cloudevents-sdk-paho-mqtt/Cargo.toml @@ -11,7 +11,7 @@ description = "CloudEvents official Rust SDK - Mqtt integration" [dependencies] cloudevents-sdk = { version = "0.3.0", path = ".." } lazy_static = "1.4.0" -paho-mqtt = "0.8" +paho-mqtt = "0.9.1" chrono = { version = "^0.4", features = ["serde"] } [dev-dependencies] diff --git a/cloudevents-sdk-paho-mqtt/src/lib.rs b/cloudevents-sdk-paho-mqtt/src/lib.rs index ff58243a..e1c76030 100644 --- a/cloudevents-sdk-paho-mqtt/src/lib.rs +++ b/cloudevents-sdk-paho-mqtt/src/lib.rs @@ -1,5 +1,4 @@ -//! This library provides Mqtt protocol bindings for CloudEvents -//! using the [paho.mqtt.rust](https://github.com/eclipse/paho.mqtt.rust) library.\\ +//! This library provides Mqtt protocol bindings for CloudEvents using the [paho.mqtt.rust](https://github.com/eclipse/paho.mqtt.rust) library.\\ #[macro_use] mod headers; mod mqtt_consumer_record; diff --git a/cloudevents-sdk-paho-mqtt/src/mqtt_producer_record.rs b/cloudevents-sdk-paho-mqtt/src/mqtt_producer_record.rs index ecf1184b..8e6d4d92 100644 --- a/cloudevents-sdk-paho-mqtt/src/mqtt_producer_record.rs +++ b/cloudevents-sdk-paho-mqtt/src/mqtt_producer_record.rs @@ -135,13 +135,15 @@ impl MessageBuilderExt for MessageBuilder { match version { MQTT_5 => { - self = self.properties(message_record.headers.clone()); + self = self.properties(message_record.headers); } _ => (), } - if let Some(s) = message_record.payload.as_ref() { - self = self.payload(s.to_vec()); + match message_record.payload { + Some(s) => + self = self.payload(s), + None => () } self