Skip to content

Commit

Permalink
Merge pull request #121 from qm3ster/subscribe_many_with_options_one
Browse files Browse the repository at this point in the history
Set `opts` if calling `subscribeMany` with 1 topic
  • Loading branch information
fpagliughi authored Apr 23, 2021
2 parents 798b151 + 05b8861 commit 059c2f3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/response_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 059c2f3

Please sign in to comment.