-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set opts
if calling subscribeMany
with 1 topic
#121
Set opts
if calling subscribeMany
with 1 topic
#121
Conversation
Thanks so much for the PR. But to answer your questions...
I'm thinking the Builder should handle all cases properly. Maybe like:
Does that seem right? |
fn subscribe_many_options<S: Into<ffi::MQTTSubscribe_options>, I: IntoIterator<Item = S>> (&mut self, opts: I) -> &mut Self {
let mut opts = opts.into_iter();
match opts.size_hint() {
(_, Some(0)) => {}
(1, Some(1)) => self.copts.subscribeOptions = opts.next().unwrap().into().copts,
_ => {
let opts: Vec<_> = opts.map(Into::into).collect();
match &opts {
[] => {}
[opts] => self.copts.subscribeOptions = opts,
_ => self.data.sub_opts = Some(opts),
}
}
}
} (lol) Or, on the other hand, it can take a |
Oh, yeah, But... the whole point of the top crate is to hide the underlying C implementation. So I don't want to expose the C (ffi) types to the apps. I've been slowly removing the places where they leaked through in earlier versions. The goal would be that when we finally reach a v1.0, we would have an API that wouldn't need to change if we got rid of the C lib and totally replace it with 100% Rust. I don't know when I might have the time to do that without a sponsor, but that's the idea. As for removing |
9cb2eb1
to
51bf55e
Compare
Okay, I moved it to |
Oh, cool. I've been meaning to get rid of all those On a quick scroll through, all of those clippy changes look pretty good, but it will take me a while to go through all of them and test. Hopefully I can get to it this weekend. |
Oh dang, shot myself in the foot again I have :v |
Yeah, I appreciate keeping the clippy stuff in a separate commit, but in general, it's better to keep the whole PR smaller and focused. This isn't one of the more popular Paho libraries (yet!), but there are still thousands of pople/companies using it in production, so we need to be careful with changes so as not to break the code or the API unnecessarily. |
51bf55e
to
05b8861
Compare
Moved clippy changes out of the PR, pls marge :v |
fixes #120
Concerns:
ResponseOptionsBuilder::subscribe_many_options
instead?+stable
and+nightly
, this should probably be addressed separately. Probably not checked in CI. I tried to format sensibly by hand.