fix(nmrs): add Send bound to for_each_access_point callback future#330
Conversation
There was a problem hiding this comment.
Thank you for this! LGTM!
If you don't mind, could you please just reword your commit to follow standards expressed in the contribution guidelines?
Send bound to for_each_access_point callback future
The Box<dyn Future + 'a> in the helper's where-clause lacks a + Send bound, making every downstream future !Send and blocking callers that use the default multi-threaded tokio runtime. The bound is always satisfiable (NMAccessPointProxy is Send + Sync, captured values are all Send) so adding + Send is a no-op for existing callers. AI disclosure (per CONTRIBUTING.md): authored with Claude Code. I hit the !Send error in a downstream project, described the symptom, and Claude located the missing bound in util/utils.rs, verified it was safe to add, wrote the patch, and ran the tests. I reviewed the diff before opening the PR.
97854e1 to
774c95c
Compare
|
@cachebag Thanks for the quick review! I edited the PR description and the commit message as described in the contributing guide. One unrelated question while I'm here: the repo has a gitlink entry for I worked around it in my fork by removing the gitlink, but the proper fix is probably either adding a |
Yes, this was left over from me trying to include the AUR repo as a submodule, which I have learned was quite useless. Never cleaned it up. A follow up PR would be appreciated! Thanks for the heads up. |
|
@cachebag I also noticed that the AUR repo is either private or removed. Is there any reason for this? |
It's not private, I just haven't uploaded a mirror to GitHub yet. Yet another thing I should have done a long time ago but never did. |
Classic story — created a project for personal use, uploaded it to GitHub, suddenly people start using it and complaining in issues :D |
Haha pretty much! I'm more than happy to address them though. It's quite heartwarming to see people use |
Both of our PRs on upstream nmrs have merged: - cachebag/nmrs#330 (Send bound on for_each_access_point) - cachebag/nmrs#331 (stale nmrs-aur gitlink removal) The latest published crates.io release (2.2.0) still predates both, so we stay on a git patch until a new version is cut — but the patch now points at upstream master pinned to commit 352f57e instead of our local fork branch. The old fork branch `okhsunrog/nmrs#fix/send-bounds-for-each-ap` becomes unreferenced after this; it can stay around as a safety net or be deleted at any time since upstream has the same content. Drop this [patch.crates-io] block entirely once nmrs cuts a new release and bump core/Cargo.toml's nmrs constraint to it. Verified all four slint-ui + tui profiles build clean against the upstream pin (linuxkms, desktop, desktop-mock, tui) and core wifi tests still pass.
The
Box<dyn Future<Output = ...> + 'a>infor_each_access_point'sF: FnMutbound is missing a+ Sendclause. Every future that awaits this helper (transitively:list_networks,current_network_info, and the publicNetworkManagermethods that call them) ends up!Send, which blocks callers from running nmrs on a default multi-threaded tokio runtime:This trips at every
tokio::spawnsite in any GUI/server/CLI app that uses#[tokio::main](the defaultrt-multi-threadflavor).The bound is always satisfiable:
NMAccessPointProxyisSend + Sync— zbus's#[proxy]-generated proxies areSend + Syncwhenever the backingConnectionis, which it is on both tokio and async-io runtimes in zbus 5.x.core::scan::list_networksandmonitoring::info::current_network_info— only captureSendvalues (Arc<str>,String, primitives) and only.awaiton proxy method calls whose outputs are allSendprimitives (u8,u32,Vec<u8>,String, etc.)..awaitholds anRc,RefCell,MutexGuard, or any other well-known non-Sendtype.Adding
+ Sendto the helper's where-clause makes both existing callersSend-compatible with no call-site changes. All 86 tests and doctests in the workspace still pass. The crate now builds cleanly when consumed from a multi-threaded tokio runtime.Context: discovered this while wiring nmrs into the archinstall_zfs installer GUI, which uses Slint on top of
#[tokio::main]and spawns wifi work viatokio::spawn. Without this fix the crate is effectively unusable from default tokio setups.AI disclosure (per CONTRIBUTING.md): this fix was authored with Claude Code. I hit the
!Senderror in my downstream project, described the symptom, and Claude read the nmrs source, located the missing bound inutil/utils.rs::for_each_access_point, verified from the code that adding+ Sendwas safe (proxy isSend + Sync, no non-Sendcaptures), wrote the patch, and ran the full test suite to verify. I reviewed the diff before opening the PR.