From 51bf55ea49655a0962c9bd78c2d64ba183bfbb8c Mon Sep 17 00:00:00 2001 From: qm3ster Date: Fri, 23 Apr 2021 02:53:44 +0300 Subject: [PATCH] Set `opts` if calling `subscribeMany` with 1 topic --- src/response_options.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/response_options.rs b/src/response_options.rs index 74e0f8f..ef1f163 100644 --- a/src/response_options.rs +++ b/src/response_options.rs @@ -172,7 +172,12 @@ impl ResponseOptionsBuilder { /// Sets a single set of subscribe options - for a call to subscribe_many() pub fn subscribe_many_options(&mut self, opts: &[SubscribeOptions]) -> &mut Self { - self.data.sub_opts = Some(opts.iter().map(|opt| opt.copts).collect()); + match opts { + [] => {} + // This is necessary, as the `MQTTAsync_subscribeMany` paho.mqtt.c function uses `opts` over `optlist` when `count <= 1` + [opts] => self.copts.subscribeOptions = opts.copts, + _ => self.data.sub_opts = Some(opts.iter().map(|opt| opt.copts).collect()) + } self }